outlook trying to close itself after creating new mail

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

outlook trying to close itself after creating new mail
 
lpl




Posts: 2
Joined: 2011-12-19
Hi,

We use Outlook Security Manager 2010 VCL with Outlook 2010 and have one issue:

If outlook is closed and we try to create a new mail with security off, the new mail opens and the popup "Do you want to save change?" directly appears.
It seems like outlook is trying to close itself right after the new mail is created.

Our code in delphi 2009:


  SecurityManager := TOlSecurityManager.Create(nil);
  try
    try
      OutlookApplic := GetActiveOleObject('Outlook.Application') as OutlookApplication;
    except
      OutlookApplic := CreateOleObject('Outlook.Application') as OutlookApplication;
    end;
    SecurityManager.ConnectTo(OutlookApplic);
    SecurityManager.DisableOOMWarnings := True;
    SecurityManager.DisableCDOWarnings := True;
    SecurityManager.DisableSMAPIWarnings := True;    

    try
      MailItem := OutlookApplic.CreateItem(olMailItem) as _MailItem;
      //... Lines where we insert all the information in the MailItem
      MailItem.Display(False);
    finally
      OutlookApplic := nil;
    end;
  finally
    SecurityManager.DisableOOMWarnings := False;
    SecurityManager.DisableCDOWarnings := False;
    SecurityManager.DisableSMAPIWarnings := False;
    SecurityManager.Free
  end;


It seems like commenting the line "SecurityManager.Free" prevents outlook from trying to close. The same code worked fine with SecurityManager 2009 and with outlook 2007.

This problem does not appear if outlook is already running before executing the code.

Do you have any idea how we could handle this?
Posted 19 Dec, 2011 07:33:52 Top
Renat Tlebaldziyeu


Add-in Express team


Posts: 132
Joined: 2010-02-15
Hello,

I'm sorry, but you can't disable both OOM and Simple MAPI warnings using one instance of Security Manager.
Please try to comment out the following lines in your code:

...
SecurityManager.DisableCDOWarnings := True; 
SecurityManager.DisableSMAPIWarnings := True;
...
SecurityManager.DisableCDOWarnings := False; 
SecurityManager.DisableSMAPIWarnings := False;
...


Also please note that if you use Security Manager with Outlook 2010 and use the ConnectTo method you also need to use the Disconnect method or release the Security Manager instance. Here is the example:

...
SecurityManager.ConnectTo(OutlookApplic);
SecurityManager.DisableOOMWarnings := True;
...
SecurityManager.DisableOOMWarnings := False; 
SecurityManager.Disconnect(OutlookApplic);
...


Did it help?
Posted 19 Dec, 2011 08:17:25 Top
effala




Posts: 2
Joined: 2011-12-19
Thank you for the fast answer.
I commented DisableCDOWarnings and DisableSMAPIWarnings lines.

I followed your example but if I use "SecurityManager.Disconnect(OutlookApplic)" outlook will also try to exit on that line.
Posted 19 Dec, 2011 10:08:40 Top
Renat Tlebaldziyeu


Add-in Express team


Posts: 132
Joined: 2010-02-15
Hello effala,

I remember the issue you described. You can try to use a workaround to avoid this:
1. Save the EntryID of the created mail item;
2. Don't call the Display method;
3. Switch the security on (call the Disconnect method);
4. Create a new Outlook application instance;
5. Find the mail item with the EntryID you saved before using the GetItemFromID method of the Outlook Namespace class;
6. Call the Display method for the found item.

Did it help?
Posted 19 Dec, 2011 10:31:57 Top