Sending an email message with an attachment

B

BP

HI,
Using Access, Word and Outlook 2000. I'm using the "merge it with Word"
option in Access. However, I can't find.... how do I add an attachment like
I would in a "normal" email message. I need to attach a pdf file.

Help?? Thanks in advance.
 
A

Alastair MacFarlane

To my knowledge there is no ability to attach documents
using the method you mentioned. You would need to use the
Outlook Object Library to create an instance of Outlook to
send the e-mail with the attachment.

You can use the code below to do this.

Alastair MacFarlane

Option Explicit

Public Sub MessageToSend()
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
Set objOutlookRecip = .Recipients.Add
("[email protected]")
.Subject = "Quarterly Performance Information"
.Importance = olImportanceHigh
Set objOutlookAttach = .Attachments.Add("A:\Test.pdf")
.Body="Hello!"
.Send
End with
exitSub:
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
Set objOutlookAttach = Nothing
Exit Sub
End Sub
 
B

BP

Thank you for this code. However, I don't know how I tap into my Access
query for the email addresses. Is that something you can easily point out
to me....? Let's say I have a field called "email_address" in a query
called "Particpant Query". Thanks again for your time.
 
Top