Automation

  • Thread starter Thread starter Wendy
  • Start date Start date
W

Wendy

I have successfully sent a current record from an Access
form into a Word 2000 template...and printed. I would now
like to email the same word document from access...is
this possible? Thank you.
 
Yes, this is possible. You would save the word document
using the document object of the documents collection and
then use the following code (making sure you have a
refence to outlook in your access database):

Public Sub SendDOCFile()
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
("(e-mail address removed)")
objOutlookRecip.Type = olTo
.Subject = "Important Information"
.Importance = olImportanceHigh
.HTMLBody = "Hello"
Set objOutlookAttach = .Attachments.Add("c:\word.doc")
.Send
End With
exitsub:
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
Set objOutlookAttach = Nothing
Exit Sub
End Sub
 
Back
Top