本文介绍了Outlook互操作服务在Windows任务计划程序中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我开发了一个控制台应用程序来创建OUTLOOK会议请求。当我在Visual Studio中运行它时,它完美地工作。但是当我在任务计划程序中安排它时,它不起作用。它给了我波纹错误。 错误:操作不可用(HRESULT异常:0x800401E3(MK_E_UNAVAILABLE)) 以下是我的代码。 public MeetingDVO sendOneTimeMeeting(MeetingDVO dvo) { log.Info( In side Send Onetime Meeting); object outlookObject = null ; Outlook.Application oApp = null ; Outlook.AppointmentItem agendaMeeting = null ; 帐户acc = null ; string status = string .Empty; 尝试 { outlookObject = Marshal.GetActiveObject( Outlook.Application); if (outlookObject!= null ) { log.Info( Marshal Object Created); oApp = new Outlook.Application(); } 其他 { oApp = new Microsoft.Office.Interop.Outlook.Application(); } if ( true ) { log.Info( 创建outlook对象); // oApp = new Outlook.Application(); // oApp = CreateOrAttachToOutlookApplication(); log.Info( 对象创建); agendaMeeting =(Outlook.AppointmentItem)oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem); log.Info( agendaMeeting Object created); acc = SetAccount(oApp); log.Info( 创建帐户); if (agendaMeeting!= null ) { log。信息( 在账户IF); Outlook.NameSpace nameSpace = oApp.GetNamespace( MAPI); log.Info( 命名空间); agendaMeeting.MeetingStatus = Microsoft.Office.Interop.Outlook.OlMeetingStatus.olMeeting; agendaMeeting.Location = dvo.Location; agendaMeeting.Subject = dvo.Subject; agendaMeeting.Body = dvo.Body; agendaMeeting.Start = dvo.TimeSlot; agendaMeeting.Duration = dvo.Duration; // agendaMeeting.RequiredAttendees [email protected]; [email protected]; agendaMeeting.RequiredAttendees = [email protected]; // agendaMeeting.RequiredAttendees [email protected]; // agendaMeeting.ForceUpdateToAllAttendees = true; // agendaMeeting.ResponseRequested = true; ((Outlook._AppointmentItem)agendaMeeting).SendUsingAccount = acc; ((Outlook._AppointmentItem)agendaMeeting).Send(); dvo.EntryID = agendaMeeting.EntryID; dvo.Remarks = MeetingSucess; } else dvo.Remarks = MeetingError + : + 会议对象为空 ; } } catch (System.Exception ex) { log.Info(ex。 InnerException + :::::: MESSAGE ---- + ex.Message); dvo.Remarks = MeetingError + : + ex.Message; } 最后 { oApp = null ; agendaMeeting = null ; acc = null ; } return dvo; } 有什么建议吗?解决方案 好吧,我可以告诉你错误信息,结合你的代码: outlookObject = Marshal.GetActiveObject(Outlook.Application); 表示在调用时Outlook似乎没有运行。 I have developed a console application to create OUTLOOK meeting requests. It is perfectly working fine when Im running it in Visual Studio. But when I schedule it in the Task Scheduler, it does not work. It gives me the bellow error.Error : Operation unavailable (Exception from HRESULT: 0x800401E3 (MK_E_UNAVAILABLE))below is my code.public MeetingDVO sendOneTimeMeeting(MeetingDVO dvo) { log.Info("In side Send Onetime Meeting"); object outlookObject = null; Outlook.Application oApp = null; Outlook.AppointmentItem agendaMeeting = null; Account acc = null; string status = string.Empty; try { outlookObject = Marshal.GetActiveObject("Outlook.Application"); if (outlookObject != null) { log.Info("Marshal Object Created"); oApp = new Outlook.Application(); } else { oApp = new Microsoft.Office.Interop.Outlook.Application(); } if (true) { log.Info("creating outlook Object"); //oApp = new Outlook.Application(); //oApp = CreateOrAttachToOutlookApplication(); log.Info("Object created"); agendaMeeting = (Outlook.AppointmentItem)oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem); log.Info(" agendaMeeting Object created"); acc = SetAccount(oApp); log.Info(" Account created"); if (agendaMeeting != null) { log.Info(" in side Account IF"); Outlook.NameSpace nameSpace = oApp.GetNamespace("MAPI"); log.Info(" Namespace"); agendaMeeting.MeetingStatus = Microsoft.Office.Interop.Outlook.OlMeetingStatus.olMeeting; agendaMeeting.Location = dvo.Location; agendaMeeting.Subject = dvo.Subject; agendaMeeting.Body = dvo.Body; agendaMeeting.Start = dvo.TimeSlot; agendaMeeting.Duration = dvo.Duration; //agendaMeeting.RequiredAttendees = "[email protected];[email protected]"; agendaMeeting.RequiredAttendees = "[email protected]"; //agendaMeeting.RequiredAttendees = "[email protected]"; //agendaMeeting.ForceUpdateToAllAttendees = true; //agendaMeeting.ResponseRequested = true; ((Outlook._AppointmentItem)agendaMeeting).SendUsingAccount = acc; ((Outlook._AppointmentItem)agendaMeeting).Send(); dvo.EntryID = agendaMeeting.EntryID; dvo.Remarks = MeetingSucess; } else dvo.Remarks = MeetingError + " : " + "Meeting Object is Null"; } } catch (System.Exception ex) { log.Info(ex.InnerException +":::::: MESSAGE----"+ex.Message); dvo.Remarks = MeetingError + " : " + ex.Message; } finally { oApp = null; agendaMeeting = null; acc = null; } return dvo; }any suggestions? 解决方案 Well, I can tell you that the error message, combined with your code:outlookObject = Marshal.GetActiveObject("Outlook.Application");means that Outlook doesn't appear to be running at the time the call is made. 这篇关于Outlook互操作服务在Windows任务计划程序中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 09-02 01:14