0
votes

I have a VSTO addin with Outlook. I currently use the "Sent Items" Folder in my Items.ItemAdd() event to intercept the email to process and save it into a depository. Everything works Ok if I create new email and send from my Outlook, BUT if I open a local PDF document in Acrobat Reader and click on "Send file by email" toolbar button, use Outlook as default, it opens a new email, fill up the email address (to myself), the Items.ItemAdd() event is never called? I do see the email arrives in my "Sent Items" folder.

1
Please show the code that sets up the event handler and processes the event. - Dmitry Streblechenko
Sorry did not see your comment. Here is some code - P. Ng
I don't see any code. Can you edit your question and add code? - Dmitry Streblechenko
private static Outlook.MAPIFolder m_sentFlder=null; private static Outlook.Items sentitems=null; public static bool SubscribeSentFolder(object Item) { m_sentFlder=((Outlook.MailItem)Item).SaveSentMessageFolder; if (m_sentFlder != null) { sentitems=m_sentFlder.Items; sentitems.ItemAdd += Items_ItemAdd; return true; } } private static void Items_ItemAdd(object item) { object mapiOb=null; if (item is Outlook.MailItem) { mapiObject=((Outlook.MailItem)Item).MAPIOBJECT; if (mapiOb !=null) Process(mapiOb); } } - P. Ng
Check if SubscribeSentFolder method actually runs. Other than that, it looks fine to me. Can you check that the event is fired in OutlookSpy (I am its author - dimastr.com/outspy): go to the Sent Items folder, click Folder button on the OutlookSpy ribbon, select the Items property, click Browse. In the Items window, go to the Events tab and look at the log at the bottom of the window as you send from Adobe Reader. - Dmitry Streblechenko

1 Answers

0
votes

Outlook may not wait until your mail is sent out actually when you sent items that way. It seems the mail item was put to the Sent Items folder after Outlook was closed or before your add-in subscribes to the event at the next startup.

A possible solution is to mark items put into the repository (it can be a user property or any other moniker) and scan the folder at each start for any unprocessed items. If you find any do the process for them.

For users with an Exchange Server account (non-Cached Exchange Mode or Cached Exchange Mode), the event will fire only for messages that are sent at the server after Outlook has started. The event will not fire for messages that are synchronized in Cached Exchange Mode immediately after Outlook starts, nor for messages that are already on the server when Outlook starts in non-Cached Exchange Mode.