Word 2003 Mailmerge to Outlook 2003 Causes Security Warning

Add-in Express™ Support Service
That's what is more important than anything else

Word 2003 Mailmerge to Outlook 2003 Causes Security Warning
Word 2003 Mailmerge to Outlook 2003 Causes Security Warning 
Guest


Guest



Just Gave your Example a try

Still get the runtime Error but with a bit more Information
The Line
Call SecurityManager.ConnectTo(OutlookApp)

Causes

"The Parameter is incorrect"
-2147024809 (80070057)

Donít Know if these have anything to do with it. It is exacly wats happening but your not using any Bitmaps in your example.
http://support.microsoft.com/default.aspx?scid=kb;en-us;242319
Posted 18 Mar, 2005 11:22:09 Top
Guest


Guest


If Think Im On to Something

The Following call to connectTo

Call SecurityManager.ConnectTo(OutlookApp)

Produces
"The Parameter is incorrect"
-2147024809 (80070057)

When Outlook 2003 is connected to a reomte Exchange Server using RPC over HTTP. It Does Not produce the error For a Stand alone POP3 with PST. Im not sure if the error occurs if Outlook is directly connected to exchange on the same LAN

Therefor. Your Connect to Call is not aware of some difference in the outlook object that exists when outlook is connect to exchange RPC over HTTP. :-)
Posted 18 Mar, 2005 11:41:56 Top
Dmitry Kostochko


Add-in Express team


Posts: 2745
Joined: 2004-04-05
Hi Darrel,

It seems I will never be able to understand VB. I am testing the code in the debug-mode, i.e. open the source code in IDE, set the breakpoint, press F5. Everything works correctly. Now just by accident I run the project without debugging. Oops, got the exception. How could this be?

Thus, the following code works:
On Error Resume Next
Call SecurityManager.ConnectTo(OutlookApp)
SecurityManager.DisableOOMWarnings = True


Posted 18 Mar, 2005 12:02:27 Top
Guest


Guest


I Have Removed IDTExtensibility2 and used the Native AddInEvents and produced the same issue. It is safe to presume IDTExtensibility2 does not have anything to do with it.

If I Add On Error Resume Next to the Routine where you perform the mail merge it works. Remove On Error Resume Next the Errors return which means the errors are occuring but if ignored seem to be succesful.

Conclusion
SecurityManager.ConnectTo is causing an error that if ignored seems to still work.

Possible Reasons:

1. When Outlook is being accessed by Words Mailmerge there is a timing issue or race condition that is preventing or breaking whatevery you perform in the connectTo

2. ConnectTo Expects to receive a Generic Object instead of an explicit outlook.application Object. Microsoft is Moving away from Generic (LateBinding Objects) to Specific (Early Binding objects) in .NET. Office 2003 Is closer to the Early Binding Examples. If Connect To Expects a a Generic object then your presuming Late Binding which means windows figures out what kind of object it's working with only when something forces it to do so. Try Changing your Connectto Sub Routine to only accept outlook.application objects e.g. declare the type.


I also think this has something to do with Word 2003's interaction with Outlook 2003 and or the IDTExtensibility2. You are probably aware that in VB 6.0 with Offfice 11.0 objects that IDTExtensibility2 is not necessary. The Events that IDTExtensibility2 creates are already a part of the AddIn. IDTExtensibility2 is now primarliy for backward compatability.


Hope this Helps I would not like to leave the On Error Resume Next because who knows what other issues may appear that we wont see. By The Way I get the Error from SecurityManager.ConnectTo no matter what outlook object object I connect to. Also The On Error explains why you didnít see it in debug mode. Debug Mode Slows the process down enough to avoid the error.

Regards
Darrell

PS. I Changed the Email addresses in your sample so I wont inundate you with email :-)
Posted 18 Mar, 2005 16:05:36 Top
Dmitry Kostochko


Add-in Express team


Posts: 2745
Joined: 2004-04-05
Hi Darrell,

Thank you for cooperation, your ideas and suggestions. I hope they will help us to make OSM a perfect product.

Posted 19 Mar, 2005 08:47:49 Top
Guest


Guest


Dmitry,

Thanks for your help. We devlopers are always at the mercy of some screwy Microsoft Qwerk. and You tool does a good job of addressing one the most rediculous things Microsoft ever did.

After using the On Error Resume next to solve the issue i began to reintroduce the method back into my add-in and discovered a peice of information that might help you put this one to bed.

1. There is definatly some type of timing issue in the Connectto Call that is what causes us to use the On Error Resume NExt in the first place.

2. In my Tool if Declare...
Dim WithEvents objApplication As outlook.Application
... And Initialize it in the OnConnection Event

In the objApplication ItemSend Event I was using...
SecurityManager.DisableOOMWarnings= True
(Various Misc Code)
SecurityManager.DisableOOMWarnings= False
... To ensure that All Mail being sent is recorded in a centralized Database

Using SecurityManager.DisableCDOWarnings = True or any references to your tool in this particular event really exaserbates the issue

Conclusion
Too many calls to your tool in too short a time manifest some type of race condition. This is further proved by the Mail merge because thats exactly whats happening. I think whats happening is that for each E-mail the Mail merge creates it creates an Instance to an Outlook Object. Since your tool is designed to Intercept the Secutity warnings in the object your sitting between the source (In this case Word) and the Destinantion (An unknown Instance of the Outlook Object created or being used by word)

Current Solution
<<On Connection Event>>
On Error Resume Next
' Set a reference to the host application Declared as Object...
' Dont Think I Need this one will let you know
Set oHostApp = Application

' Set a reference to the host application Declared WithEvents...
Set objApplication = oHostApp

' Set Global App Obect for use from Forms
'Global Objects cant be declared WithEvents
Set gApplication = oHostApp

' Set Global Name Space Obect for use from Forms
Set gNamespace = objApplication.GetNamespace("MAPI")

' Set Global Explorer Obect for use from Forms

<<End On Connection Event>>


This Seems to work without Creating an additional Outlook Object. YOu still need the On Error Resume next Before the Call to ConnectTo

<< Mailmerge Code >>
On Error Resume Next
Call SecurityManager.ConnectTo(objApplication)
SecurityManager.DisableOOMWarnings = True
wdApp.ActiveDocument.MailMerge.Execute Pause:=False
SecurityManager.DisableOOMWarnings = False


<< ItemSendEvent >>
Make Sure there are not any calls to your Tool in the objOutlook Item Send Event
E.g. SecurityManager.DisableOOMWarnings= True


Hope this Continues to help. I look forward to learning what you discover in the Call to SecurityManager.ConnectTo(objApplication)


Posted 19 Mar, 2005 09:49:13 Top
Dmitry Kostochko


Add-in Express team


Posts: 2745
Joined: 2004-04-05
Hi Darrell,

Thank you again. We will let you know what we will find there.



Posted 20 Mar, 2005 09:33:17 Top
Guest


Guest


I think Im about to give up
Add the following to the Mailmerge code and the security warning is back.

wdApp.ActiveDocument.MailMerge.MailAsAttachment = True

I know this isn't your tool per say. Clearly Microsft can't get their heads out of their b... when it comes to mail merge. The more I dig into mail merge the worse it gets. Problem is I need a clean way to use Word Templates as a source for a mailmerge to Outlook without all the sill security warnings.

Whats the Point of sending a 500 record mail via mailmerge if the user has to say Ok 500 Times.

Thanks again for all the help
Posted 20 Mar, 2005 14:40:16 Top
Dmitry Kostochko


Add-in Express team


Posts: 2745
Joined: 2004-04-05
Hi Darrell,

wdApp.ActiveDocument.MailMerge.MailAsAttachment = True

Yes, you are right. I have just run into the same.

Do you have to obligatory send them as attachments? Or can you send them as mail bodies?


Posted 21 Mar, 2005 08:35:00 Top