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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mailmerge to Email in Word question

Status
Not open for further replies.

mmorancbt

IS-IT--Management
Nov 11, 2002
367
US
How's that for a subject??

Is there a way to include an attachment when using documentobject.mailmerge. I can create or have the user create the document text but cannot add an attachment. If I use word as an email editor, I cannot do a mailmerge to reach all recipients.

Any ideas? Matthew Moran
The I.T. Career Builder's Toolkit
 
Matthew,

If I understand your question correctly, the following code should work. It assumes you have a correctly-configured MAPI mail client (like Outlook) on your machine.

Sub TestEmailMerge()
'
' TestEmailMerge Macro
' Macro recorded 01/06/03 by Luke Deese
'
ActiveDocument.MailMerge.DataSource.QueryString = _
"SELECT * FROM C:\My Documents\MergeDataSource.xls WHERE ((Email IS NOT NULL ))" _
& ""
With ActiveDocument.MailMerge
.Destination = wdSendToEmail
.MailAsAttachment = True
.MailAddressFieldName = "Email"
.MailSubject = "Announcing Test!"
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=True
End With
End Sub

Hope that helps!

VBAjedi
 
I had something like that but what about the body of the email message.

In the example above, the text of the word document becomes the attachment.

What I would like to do (and I didn't want to actually start programing to the Outlook object model) is create a word document that has the text and then allow the user to select 1 or more files as attachments.

The word mailmerge object would create the body of the message while the attachments would simply show up as attachments.

Does that make sense?

Thanks. Matthew Moran
The I.T. Career Builder's Toolkit
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top