Email Merge Displays a dialog Choose Profile

M

Michael Moschella

I can do a Mail Merge and then send it out as email
without any problem as long as Outlook is running. If I
do not have Outlook Running it brings up a dialog titled
Choose Profile (with a selection "MS Exchange Settings").
I tried opening up an instance of Outlook.Application but
that did not help. Is there some setting I can set in the
Outlook.Application object or the Word.Doc.MailMerge object
to "MS Exchange Setting" so this dialog will not show ?
Do I need to always startup the Outlook.exe?The
MAPI.Session object has something called Logon
ProfileName, can I set this some place in either of these
two objects?

I am running Word 2000 and Outlook 2000 on Windows 2000
using vb6 to write the code.
See code below

Thanks
Mike

Private WithEvents mOut As Outlook.Application
Private WithEvents mWrd As Word.Application
Private WithEvents mDoc As Word.Document

Private Sub cmdGenerate_Click()
On Error GoTo eh
bNew = False
Set mWrd = CreateObject("Word.Application")

If Not (bNew) Then
Set mDoc = mWrd.Documents.Open
("C:\MailMerge\Demo\TempTemplate.doc")
Else
Set mDoc = mWrd.Documents.Add
End If

If Not (bNew) Then
mDoc.MailMerge.MainDocumentType =
wdFormLetters
mDoc.MailMerge.OpenDataSource
Name:="C:\MailMerge\Demo\data1.dat"
End If
Set mOut = CreateObject("Outlook.Application")

mWrd.Visible = True
mWrd.Activate
Screen.MousePointer = vbDefault
mDoc.MailMerge.MailAsAttachment = True
mDoc.MailMerge.MailAddressFieldName
= "Email_Address"
mDoc.MailMerge.MailSubject = "GreatTest"
mDoc.MailMerge.Destination = wdSendToEmail
mDoc.MailMerge.Execute

Set mMsg = Nothing
Set mOut = Nothing
Unload Me
Exit Sub

eh:
Unload Me

End Sub
 
P

Peter Jamieson

I doubt if you will get a definitive answer in this group and you probably
need to ask in an Outlook group, but from experiments here I think you are
probably on the right lines, e.g. if you were using VBA you might have

Dim oa As Outlook.Application
Dim ons As Outlook.NameSpace
Set oa = CreateObject("Outlook.Application")
Set ons = oa.GetNamespace("MAPI")
ons.Logon "the profile name", "", False, False
With ActiveDocument.MailMerge
.Execute
End With
ons.Logoff
Set ons = Nothing
Set oa = Nothing

This seems to work whether or not Outlook is running, but I don't know what
happens if for example you need to ensure that you log on to the same
profile as Outlook is using.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top