开发者

Outlook addin exception

开发者 https://www.devze.com 2023-01-04 06:11 出处:网络
hi i wrote following code for save some mails (already imported to data grid using MAPI) to selected inbox folder in button click

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

精彩评论

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