本文介绍了从Windows服务中读取Outlook邮件时出错。以下是例外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! IN ExceptionSystem.Runtime.InteropServices.COMException(0x80020009):无法完成操作。你没有连接。 at Microsoft.Office.Interop.Outlook.NameSpaceClass.GetDefaultFolder(OlDefaultFolders FolderType) at MyFirstService.Service1.TESTmail(Object source,ElapsedEventArgs e)在C:\ Users \ Pankaj.Joshi \Documents\C#_Program\MyFirstService \ MyFirstService\Service1.cs:第56行 我尝试了什么: 我尝试了什么: 1展望._Application app = new outlook.Application(); 2 outlook._NameSpace ns = app.GetNamespace(MAPI); //在线下获取错误 3 outlook.MAPIFolder inbox = s.GetDefaultFolder(outlook.OlDefaultFolders.olFolderInbox); 4 //ns.SendAndReceive(true); 5 inbox.Items.Sort([ReceivedTime],true); 6 foreach(收件箱中的outlook.MailItem项目。项目) 7 { 8}IN ExceptionSystem.Runtime.InteropServices.COMException (0x80020009): Cannot complete the operation. You are not connected.at Microsoft.Office.Interop.Outlook.NameSpaceClass.GetDefaultFolder(OlDefaultFolders FolderType)at MyFirstService.Service1.TESTmail(Object source, ElapsedEventArgs e) in C:\Users\Pankaj.Joshi\Documents\C#_Program\MyFirstService\MyFirstService\Service1.cs:line 56What I have tried:What I have tried:1 outlook._Application app = new outlook.Application();2 outlook._NameSpace ns = app.GetNamespace("MAPI");// getting error on below line3 outlook.MAPIFolder inbox = s.GetDefaultFolder(outlook.OlDefaultFolders.olFolderInbox);4 //ns.SendAndReceive(true);5 inbox.Items.Sort("[ReceivedTime]", true);6 foreach (outlook.MailItem item in inbox.Items)7 {8 }推荐答案作为mentio在评论中,这个问题已经解决。但是,如果您现在遇到批处理文件的问题,请打开一个新问题并提供比您在评论中更多的详细信息,以便有人可以提供帮助。As mentioned in the comments, this issue has been resolved. However, if you are now having issues with a batch file please open a new question and provide much more detail than you did in the comments so that someone can actually help. 这篇关于从Windows服务中读取Outlook邮件时出错。以下是例外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-14 06:35