Hello,
I've been given the task to modify some mail merge code by adding email functionality.
Here is my problem:
The company wants to print the documents that do not have an email address and email those that do.
I'm not sure how to do this since there is no loop to verify
"Application.ActiveDocument.MailMerge.DataSource.DataFields("Email").value"
Any help would be greatly appreciated.
If at first you don't succeed, then sky diving wasn't meant for you!
I've been given the task to modify some mail merge code by adding email functionality.
Here is my problem:
The company wants to print the documents that do not have an email address and email those that do.
I'm not sure how to do this since there is no loop to verify
"Application.ActiveDocument.MailMerge.DataSource.DataFields("Email").value"
Code:
'Do mailmerge.
With ActiveDocument.MailMerge
.OpenDataSource Name:="SourceName" 'Specify the data source here
.Destination = wdSendToNewDocument
.Execute
End With
'Close mailmerge document
Windows(DocName).Close wdDoNotSaveChanges
'Print and quit (Print only documents that do not have an email address)
Application.PrintOut
ActiveDocument.SaveAs "C:\Letters1.doc"
Application.Quit
' How do I add this. Only send if an email address exists.
With ActiveDocument.MailMerge
.Destination = wdSendToEmail
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
Any help would be greatly appreciated.
If at first you don't succeed, then sky diving wasn't meant for you!