如何将邮件标记为已读?

时间:2016-04-04 06:28:31

标签: c# email outlook email-attachments outlook-2013

我正在使用应用程序将附件中的文件保存在未读的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);
        }

1 个答案:

答案 0 :(得分:1)

更改“NewMail.UnRead = false;” to“newMail.UnRead = false;”