我正在开发一个应用程序,用于将附件保存在未读的Outlook邮件中。
之后,我想将邮件标记为已读,这样它就不会在相同的邮件上运行。
该邮件仍被标记为未读。
我这样写:
try
{
foreach (object collectionItem in inBoxItems)
{
newEmail = collectionItem as Outlook.MailItem;
if (newEmail != null)
{
if (newEmail.Attachments.Count > 0)
{
for (int i = 1; i <= newEmail.Attachments.Count; i++)
{
string filePath = Path.Combine(destination,newEmail.Attachments[i].FileName);
newEmail.Attachments[i].SaveAsFile(filePath);
}
NewMail.UnRead = false;
NewMail.Save();
flag = true;
}
}
}
if (flag == true)
{
MessageBox.Show("saved!");
flag = false;
}
else
MessageBox.Show("not saved");
}
catch (Exception ex)
{
string errorInfo = (string)ex.Message.Substring(0, 11);
MessageBox.Show(ex.Message);
}
更改NewMail.UnRead = false;
为newMail.UnRead = false;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句