Automating Outlook from Access, with late binding

D

Dale Fye

I have users using one of my applications that are running Office 2003 and
2007. To avoid reference problems, I was hoping to use late binding to
automate sending a message with attachments from within Access. The code I'm
currently using (below) requires the appropriate reference. Can anyone
provide recommendations for modifications to this to allow late binding?

Dim omail As Outlook.MailItem
Set omail = CreateItem(olMailItem)
omail.Subject = "Email with attachment"
omail.Attachments.Add strFileName, 1
omail.Display
Set omail = Nothing
 
D

Douglas J. Steele

Try:

Const oMailItem As Long = 0

Dim oOutlook As Object
Dim omail As Object

Set oOutlook = CreateObject("Outlook.Application")
Set omail = oOutlook.CreateItem(olMailItem)
omail.Subject = "Email with attachment"
omail.Attachments.Add strFileName, 1
omail.Display
Set omail = Nothing
oOutlook.Quit
Set oOutlook = Nothing
 
Top