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 )
{
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)