I am trying to create a macro to send a word document to 4 emails per document, each coming in from it's own field
eg supplier1mail, supplier2mail, etc. and is usually going to be sent in about 10 docs per batch, data is being pulled in from an access database and email is being sent through outlook.
Subject line will always be the same and no body text is needed. Any help would be greatly appreciated as this is the first time I've really looked at VBA. Thanks.
Just to get you started, this how I did mine (before, set up your Mailing in Word) :
Sub MergeToEmail()
Dim DisPTxT As String
Dim bDone As Boolean
bDone = False
Do While bDone = False
ActiveDocument.Fields.Update
With ActiveDocument.MailMerge
.MailAddressFieldName = "Mail"
.Destination = wdSendToEmail
.SuppressBlankLines = True
' You can modify the text "Enter Your Subject Here" or
' remove the following line if you do not want a subject
.MailSubject = "Samedi 26 Avril 2014"
With .DataSource
.FirstRecord = ActiveDocument.MailMerge.DataSource.ActiveRecord
.LastRecord = ActiveDocument.MailMerge.DataSource.ActiveRecord
End With
.Execute Pause:=False
End With
If ActiveDocument.MailMerge.DataSource.ActiveRecord = _
ActiveDocument.MailMerge.DataSource.RecordCount Then
bDone = True
End If
ActiveDocument.MailMerge.DataSource.ActiveRecord = wdNextRecord
Loop
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.