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
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