Automation email

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm working on automating my emails from Access to work through Outlook. I
found a nifty code for VBA but it would seem the first line is wrong. It
reads
Dim objOutlookApp As Outlook.Application. It looks right to me but VB is
telling me User-defined type not defined. What is wrong here???
 
The code is fine, but you need to create a reference to the Outlook object
library. On the VBA menu bar select Tools | References. Scroll down the
list to 'Microsoft Outlook ##.# Object Library' (the version number will
depend on which version of Office you are using). Check the check box and
close the dialogue. All should then be fine.

Ken Sheridan
Stafford, England
 
Ken,

I've checked the Microsoft Outlook 11.0 Object Library, that's the version
we use, but it still gives me the undefined error. Not sure what I did wrong.
 
It should be OK. Try entering that line again and see if 'Outlook' appears
in the drop down list as you enter the statement. If it doesn't then check
the References dialogue again to make sure the reference has in fact been
created. Make sure you click the OK button to exit the dialogue.

Ken Sheridan
Stafford, England
 
Okay, I tried it again, but it still didn't work. 'Outlook' doesn't appear
anywhere. However, in the Reference box there are several things checked
off. Examples: Visual Basic For Applications, Microsoft Access 11.0 Object
Library, OLE Automation, and two more. When I select Access 11.0 and click
OK it should work right. Do I have to deselect the other options?
 
No, whatever you do don't deselect any of the other references. I assume by
'When I select Access 11.0 and click OK it should work right.' you meant
Outlook 11.0. In which case the answer is yes. Does the reference to
outlook show checked in the dialogue? Is it marked as broken or missing? If
the answers to these two questions are Yes and No respectively, you should
not be having any problems. Note that the references are created in each
database, not at application level, so if you've created a reference in one
file it won't apply to all databases you open; you need to create them in
each as necessary.

Ken Sheridan
Stafford
 
Oops, I actually was selecting Access 11.0, that's why it was giving me the
error. Rookie mistake. So I have the reference down now and it's good to
go, however, I've run into another snag. It's giving me a syntax error with
the following bit of code:
If Err.Number = "287" Then
MsgBox "You clicked No to the Outlook security warning. " & _
"Rerun the procedure and click Yes to access e-mail" & _
"addresses to send your message. For more information, & _
"see the document at http://www.microsoft.com/office" & _
"/previous/outlook/downloads/security.asp. " "

I think maybe this command is too much. I don't think I really need it.
Could I just delete it or no? Ken thanks so much for your help.
 
If its really superfluous to the functionality of the routine then possibly
you can delete it, I think the syntax error is simply that "287" is enclosed
in quotes. It should be:

If Err.Number = 287 Then

so before deleting it change it and see if it works OK.

Ken Sheridan
Stafford England
 
I just got rid of the error message. Now it works. Thanks for your help.
Will the automation work if I try to link it to a field in Access with a 'due
date' so the email will be sent on that date?

Ken you are a life saver. I didn't think I'd ever get this working.
 
I can't really say, for two reasons; (1) without seeing the code concerned
its difficult to comment; (2) I'm by no stretch of the imagination an Outlook
expert, so probably wouldn't know the answer anyway! Try it and see. The
Outlook discussion group would be the place for an authoritative answer,
though.

Signing off for today.

Ken Sheridan
Stafford England
 
Back
Top