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.
精彩评论