mlagrange
asked on
Behavior of Word mail merge to e-mail from Access
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?
Thanks
Mark
**************
Public Function MergeIt(Dest As String)
Dim objWord As Word.Document
Set objWord = GetObject("C:\MailMerge\Ma ilMerge.do c", "Word.Document")
' Make Word visible.
objWord.Application.Visibl e = True
' Set the mail merge data source
objWord.MailMerge.OpenData Source Name:="C:\MailMerge\MailMe rge.mdb", LinkToSource:=True, AddToRecentFiles:=False, _
SQLStatement:="SELECT * FROM [tblMailMerge]"
Select Case Dest
Case "print"
objWord.MailMerge.Destinat ion = wdSendToNewDocument
Case "email"
' Execute the mail merge.
objWord.MailMerge.MailSubj ect = "Please Read me!"
objWord.MailMerge.MailForm at = wdMailFormatPlainText
objWord.MailMerge.MailAddr essFieldNa me = "EMailAddr"
objWord.MailMerge.Destinat ion = wdSendToEmail
End Select
objWord.MailMerge.Execute
Set objWord = Nothing
MsgBox "Finished..."
End Function
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?
Thanks
Mark
**************
Public Function MergeIt(Dest As String)
Dim objWord As Word.Document
Set objWord = GetObject("C:\MailMerge\Ma
' Make Word visible.
objWord.Application.Visibl
' Set the mail merge data source
objWord.MailMerge.OpenData
SQLStatement:="SELECT * FROM [tblMailMerge]"
Select Case Dest
Case "print"
objWord.MailMerge.Destinat
Case "email"
' Execute the mail merge.
objWord.MailMerge.MailSubj
objWord.MailMerge.MailForm
objWord.MailMerge.MailAddr
objWord.MailMerge.Destinat
End Select
objWord.MailMerge.Execute
Set objWord = Nothing
MsgBox "Finished..."
End Function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok, thanks for the link
Any idea about the second part (messages sitting in the Outbox)?
Thanks
Mark
Any idea about the second part (messages sitting in the Outbox)?
Thanks
Mark
Welcome to Outlook 2002+.
In an attempt to prevent email viral propogation, Outlook now refuses to allow automated email generation without explicit user interation. Which is annoying when it's your own code, but sensible.