mausinc
mausinc

Reputation: 537

Outlook ItemAdd event raises also with sync

I am working on an Outlook Addin which will prompt the user to save an email after it is sent.

Works fine until the user has sent the email with his phone and exchange syncs the sent items folder on the users desktop. How can i only prompt the user when the email is sent on his desktop.

So can i check if email has been sent from current device only.

Thanks so much.

Solution

Raise two events :

.ItemSend =>

mail.UserProperties.Add("NameUserProperty", OlUserPropertyType.olYesNo);
mail.UserProperties["NameUserProperty"].Value = true;
mail.Save();

.ItemAdd (Sent Folder) =>

if(mail.UserProperties["NameUserProperty"].Value == true)
{
 // record message
}

Upvotes: 0

Views: 191

Answers (2)

Eric Legault
Eric Legault

Reputation: 5834

I think the only way to properly capture this is to set a flag at the time the item is sent (MailItem.Send) and then set a watch on the Sent Items folder to look for a message with the same Subject when it is added to the folder (via ItemAdd).

Upvotes: 1

Dmitry Streblechenko
Dmitry Streblechenko

Reputation: 66215

Use the Application.ItemSend event - it fires only for the messages sent by the local instance of Outlook.

Upvotes: 1

Related Questions