Behavior of Word mail merge to e-mail from Access
Posted on 2006-11-19
Hello - I worked up a very basic routine (code below) to mail merge to either a new Word doc or to e-mail, and I'm wondering if what I'm seeing is normal:
1) I'm getting prompted once about "A program is trying to access e-mail addresses...", and then again about "A program is trying to automatically send e-mail..." for EVERY e-mail in the mail merge result. Is this normal ??? Any way to prevent this?
2) It looks like these e-mail's just sit in my Outbox unless Outlook is open at the time I run the mail merge. Is this "by design"? Is there some way I can force the messages to go out automatically?
Public Function MergeIt(Dest As String)
Dim objWord As Word.Document
Set objWord = GetObject("C:\MailMerge\MailMerge.doc", "Word.Document")
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source
objWord.MailMerge.OpenDataSource Name:="C:\MailMerge\MailMerge.mdb", LinkToSource:=True, AddToRecentFiles:=False, _
SQLStatement:="SELECT * FROM [tblMailMerge]"
Select Case Dest
objWord.MailMerge.Destination = wdSendToNewDocument
' Execute the mail merge.
objWord.MailMerge.MailSubject = "Please Read me!"
objWord.MailMerge.MailFormat = wdMailFormatPlainText
objWord.MailMerge.MailAddressFieldName = "EMailAddr"
objWord.MailMerge.Destination = wdSendToEmail
Set objWord = Nothing