Email an Excel Attachment from Access

B

Bruce

Hi - I wish to email an Excel attachment from Access and have been trying to
do so with SendObject. The email sends ok but there is no attachment.

n.b. The email below is for example only

Anyone know what is wrong with my code?

Bruce

Function email()
myAttachment = "D:\AAA\ASX\Yahoo\Intraday Report.xls"
myEmail = "(e-mail address removed)"
DoCmd.SendObject , myAttachment, "", myEmail, "", "", "Intraday Update",
"Intraday Update", False, ""
End Function
 
J

JCP

Bruce if you want attach any file to outlook, try the following function:


Function EmailAttachFile()
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim AttachFile As String

AttachFile = "C:\Test.doc"

Set objOutlook = CreateObject("Outlook.Application") ' Create the
Outlook session.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem) ' Create
the message.

With objOutlookMsg
.To = "(e-mail address removed)"
.CC = ""
.BCC = ""
.Subject = "This is a test"
.Body = "Tell me if it works"
End With

If Dir(AttachFile) <> "" Then objOutlookMsg.Attachments.Add AttachFile

objOutlookMsg.Display

Set objOutlookMsg = Nothing
Set objOutlook = Nothing

End Function

you must add references to microsoft oulook

regards
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top