Outlook 插件异常
您好,我编写了以下代码,用于将一些邮件(已使用 MAPI 导入到数据网格)保存到单击按钮中选定的收件箱文件夹,
Outlook.MAPIFolder oMailFolder = null;
Outlook.Application oApp = new Outlook.Application();
Outlook.NameSpace oNS = oApp.GetNamespace("MAPI");
MailItem moveFilteredMails = null;
oMailFolder = oNS.PickFolder();
oApp = null;
oNS = null;
List<UnreadEmails> filteredList = (List<UnreadEmails>)dgvUnreadMails.DataSource;
foreach (UnreadEmails item in filteredList)
{
moveFilteredMails.Move(oMailFolder);
}
但从 pickfilder 方法选择收件箱文件夹后,它给出了一个异常:
NullReferenceExceptionException 未处理,并且未将对象引用设置为对象的实例。
请帮助查找错误
hi i wrote following code for save some mails (already imported to data grid using MAPI) to selected inbox folder in button click
Outlook.MAPIFolder oMailFolder = null;
Outlook.Application oApp = new Outlook.Application();
Outlook.NameSpace oNS = oApp.GetNamespace("MAPI");
MailItem moveFilteredMails = null;
oMailFolder = oNS.PickFolder();
oApp = null;
oNS = null;
List<UnreadEmails> filteredList = (List<UnreadEmails>)dgvUnreadMails.DataSource;
foreach (UnreadEmails item in filteredList)
{
moveFilteredMails.Move(oMailFolder);
}
but after selecting inbox folder from pickfilder method it gives a exception saying that
NullReferenceExceptionException was unhandled and Object reference not set to an instance of an object.
pls help to find the error
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您编写了
moveFilteredMails = null
。由于
moveFilteredMails
为null
,因此当您尝试将项目移入其中时,您会收到NullReferenceException
。You wrote
moveFilteredMails = null
.Since
moveFilteredMails
isnull
, you're getting aNullReferenceException
when you try to move an item into it.