I have to write a code when the user clicks on the Send button to move a mailitem to a folder My Folder and stop the sending functionality. I have achieved this through Below Code:
void Application_ItemSend(object Item, ref bool Cancel)
{
Outlook.MailItem mailItem = Item as Outlook.MailItem;
Cancel = true;
if (mailItem != null)
{
var attachments = mailItem.Attachments;
string folderPath =
Application.Session.
DefaultStore.GetRootFolder().FolderPath
+ @"\Outbox\My Outbox";
Outlook.Folder folder = GetFolder(folderPath);
if (folder != null)
{
mailItem.Move(folder);
}
}
}
My question is that I have to trigger a code piece when a mailitem arrive in the My Outbox folder. I am a newbie in VSTO and plugins . Kindly tell me how can I achieve this. Any help will be highly appreciated.