Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automate: File / Send To / Mail Recipient

Status
Not open for further replies.

GarstonMassive

Programmer
May 5, 2006
71
GB
It's possible to open a Word doc, go:

File->Send To->Mail Recipient

and send the doc as an email.

Can I automate this from Access using VBA?

Pls also see related thread:

thread705-1289920
 
I'm guessing that you have a field for the e-mail address?
If so you want to use this code on a buttons click event:

Private Sub CommandButton_Click()
On Error GoTo Err_CommandButton_Click

Dim strEmail as String
Dim strBody as string
Dim objOutlook as Outlook.Application
Dim objEmail as Outlook.MailItem
Dim strSender as String
Dim strSubject as string

strEmail= "Emailaddress@address.com"
strBody= "Whatever you want to send in the body"
strSubject= "Your Subject"

With objEmail
.To = strEmail
.Subject = strSubject
.Body = strBody
.Attachment = "Your Word File"
.Send
End With

Set objEmail = Nothing

John Green
 
I forgot to add that you will need to add Outlook's Object Library to your references.

John Green
 
John thanks for your reply but I disregarded this method some time ago as I dont want to send it as an attachment.

The bugbear is always retaining the formatting so I quite literally want to automate the process of opening the doc and going:

File->Send To->Mail Recipient.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top