Scott English
Posts: 27
Joined: 2010-01-12
|
I have the following code that's being called in an Outlook addin.
public void AccessContactEmail()
{
Outlook.Application _outlook = new Outlook.Application();
Debug.Assert(_outlook != null, "Error creating Outlook application object.");
try
{
using (AddinExpress.Outlook.SecurityManager _olSecurityManager = new AddinExpress.Outlook.SecurityManager())
{
_olSecurityManager.ConnectTo(_outlook);
_olSecurityManager.DisableOOMWarnings = true;
AccessContactEmail(_outlook);
_olSecurityManager.DisableOOMWarnings = false;
}
}
finally
{
Marshal.ReleaseComObject(_outlook);
}
}
The call to ConnectTo throws an ArgumentException with a description "Value does not fall within the expected range".
I am using Windows XP, Outlook 2003, Outlook 2003 PIAs, Outlook Security Manager 2009, and Visual Studio 2008. Please help. |
|
Eugene Astafiev
Guest
|
Hi Scott,
Why do you create a new instance of Outlook app? In Outlook add-in you don't need to call the ConnectTo method.
Please remove the following code:
Outlook.Application _outlook = new Outlook.Application();
_olSecurityManager.ConnectTo(_outlook);
and let me know whether it helps.
BTW Is it Add-in Express based COM add-in? |
|
Scott English
Posts: 27
Joined: 2010-01-12
|
Yes, it's an Add-in Express based COM add-in.
I want to create another instance of the Application object because I want to access the object from a thread other than the main thread of the add-in.
Shouldn't the security manager work in an add-in? |
|
Scott English
Posts: 27
Joined: 2010-01-12
|
OK, I found the problem. I only get that error on the main thread. If I use the add-in's OutlookApp for the main thread and create a new Application and Security Manager for other threads, it works correctly. |
|