简体   繁体   中英

Can't add a task when another instance of outlook is running

I try to add a task/appointment to outlook from windows service. I'm using such code to do this:

RDOSession session = new RDOSession();

session.Logon();

RDOAppointmentItem appo = (RDOAppointmentItem)session.GetDefaultFolder(rdoDefaultFolders.olFolderCalendar).Items.Add();

appo.Subject = lessons[i].Type;
appo.Start = lessons[i].Start;
appo.End = lessons[i].End;
appo.Save();
session.Logoff();

Everything works fine when another instance of outlook isn't running. But when it is I get such error:

Error in IMAPISession::OpenMsgStore: MAPI_E_FAILONEPROVIDER
ulVersion: 0
Error: Nie mo¿na otworzyæ (Can't open file) C:\Users\d3dek\AppData\Local\Microsoft\Outlook\Outlook.pst.
Component: Foldery osobiste (Personal folders)
ulLowLevelError: 0
ulContext: 268828930

My windows service is working on user 'd3dek'. Any ideas? I read that pst folders can work with multiple instances.

If your service and Outlook are running in diffeeren security contexts, the PST provider cannot share the PST file between different processes. What version of Outlook are you using?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM