开发者

Reading properties from a Mailitem in Outlook outbox makes it not send

I'm writing a VSTO app for Outlook 2007 that periodically checks mails in the Outbox. I can run over the MailItems and check the .Submitted property with no adverse effects. But if I read the SentOn property than the mail in Outlook stops being italicised and no longer gets sent.

I have to go mailitem.Send() to make sure it still gets sent.

e.g.

 MAPIFolder folder = Application.Session.GetDefaultFolder(OlDefaultFolders.olFolderOutbox) as MAPIFolder;
 MailItem latest = null;
 foreach (object item in folder.Items)
 {
     MailItem mailItem = item as MailItem;
     if( mailItem != null && mailItem.Submitted )开发者_JS百科
     {
         if (latest == null || mailItem.SentOn > latest.SentOn)
         {
             latest = mailItem;
         }                     

         mailItem.Send(); // have to resend as checking the sent date takes it out the queue!
     }               
 }

Seems to be the case with most properties - but .Submitted leaves it untouched. I've not changed it in anyway so how can I inspect the mail without it going. (I should add that i've got a rule that delays the mail for 1 minute so I can get the mails as they leave)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜