Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send Internet e-mail from Access VBA

Status
Not open for further replies.

klm2klm2

Programmer
Dec 24, 2002
36
US
My app needs to send an Internet e-mail message to a single recipient and with one file attached.

I have found information about how to accomlish this with Outlook, but I need for this to work with Outlook Express.

SendObject won't work because it won't allow a file to be attached.

Can anybody shed some light on how to accomplish this?

Thanks,
Kim

P.S. Access 2000, Outlook Express 6.0
P.S. Ideally, if the mail service isn't available at the time of execution, the routine will leave the message in the Outbox for future processing.
 
Hi Kim,

Check out this FAQ. It will use your default email program to send the email. Unfortuately, Outlook Express does not have a model to write code for. Outlook does but not Express. You have to either call the default email system or write code using a Mapi client. I think this FAQ will help you out.

faq705-537

HTH Have A Great Day!!!, [bigglasses]

Nathan
Senior Test Lead
 
This code should do it for you. Although this is not dependent on having Outlook express on the pc it is running on.

Dim iMsg, arrEmail
Set iMsg = CreateObject("CDO.Message")

With iMsg
.To = emailaddress@whereever.com
.From = "youremail@whereever.com"
.Subject = "Reports"
.TextBody = "See attached docs for more info."
.AddAttachment strAttachmentPath
.send
End With

Thanks,


Halfbarrel.
 
I tried the following code that was submitted by halfbarrel to send an internet e-mail.

Dim strAttachmentPath As String
Dim iMsg, arrEmail
Set iMsg = CreateObject("CDO.Message")
With iMsg
.To = "kimmedlin@yahoo.com"
.From = "youremail@whereever.com"
.Subject = "Subject line"
.TextBody = "See attached docs for more info."
.AddAttachment strAttachmentPath
.send
End With

I got the following error:

Run-time error '-2147220960 (80040220)':
The "SendUsing" configuration value is invalid.

The .send line of code was highlighted.

Any idea of how to make this work?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top