Link to home
Start Free TrialLog in
Avatar of mlagrange
mlagrangeFlag for United States of America

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\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
       Case "print"
           objWord.MailMerge.Destination = wdSendToNewDocument
       Case "email"
            ' Execute the mail merge.
            objWord.MailMerge.MailSubject = "Please Read me!"
            objWord.MailMerge.MailFormat = wdMailFormatPlainText
            objWord.MailMerge.MailAddressFieldName = "EMailAddr"
            objWord.MailMerge.Destination = wdSendToEmail
    End Select
             
    objWord.MailMerge.Execute
   
    Set objWord = Nothing
   
    MsgBox "Finished..."

End Function
Avatar of GreymanMSC
GreymanMSC

Oh, yes, it is now normal behaviour.

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.
ASKER CERTIFIED SOLUTION
Avatar of GreymanMSC
GreymanMSC

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mlagrange

ASKER

Ok, thanks for the link

Any idea about the second part (messages sitting in the Outbox)?

Thanks

Mark