开发者

Outlook addin exception

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


You wrote moveFilteredMails = null.

Since moveFilteredMails is null, you're getting a NullReferenceException when you try to move an item into it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜