Outlook MAPI session exception when outlook interface is closed
- by michele
I'm developing a email sender that retrieve data from a database, build up a MailItem with the Outlook Interop and send it.
My email sender is running by a windows service that is notified everytime there's some data to send. I'm logging on the MAPI session of Outlook without problem and everything seems to work.
But...
when someone open Outlook interface and then close, my service crash at the first attempt i call a SendAndReceive method, with an exception that report that the session is assigned to another thread.
I'm googling around for hours and i'm listening to the application_quit event, raised by the interface closing, trying to logoff and logon again to the application...but i'm still falling in the same error.
Where am i wrong?Any suggestion?
Thank you in advance