Email an Excel Attachment from Access

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

Guest

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
 
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
 
Back
Top