Trying to access properties using ADXMAPIStoreAccessor in SendMail handler, how to work around this?

Add-in Express™ Support Service
That's what is more important than anything else

Trying to access properties using ADXMAPIStoreAccessor in SendMail handler, how to work around this?
 
Dennis Smit




Posts: 9
Joined: 2010-05-13
Hi, thanks again for your time!

Within the ItemSend handler I want to get the PR_SENDER_EMAIL_ADDRESS, it seems that
I can't access these while the item is still being send. Is there a way to get an event
after the item has physically been sent so these properties are filled?

The use case is that I need to look up the sender email address in an ERP system and then
add some data to tables.

Not sure how to move forward from this point, thanks in advance for hints!

I'll make complete code snippets and post them here after you guys helped me getting this to work ;-)

Regards,
Dennis
Posted 26 Jul, 2010 17:34:24 Top
Andrei Smolin


Add-in Express team


Posts: 18829
Joined: 2006-05-11
Hi Dennis,

If e.Item in ItemSend is an Outlook.MailItem, you get Outlook.MAPIFolder mentioned in MailItem.SaveSentMessageFolder, connect to the events of the Items collection of that folder and wait for the ItemAdd event. To identify the e-mail, you can use some properties of the item being sent, say, subject.

But as far as I remeber, if the user clears "Save copies of messages in Sent Items", you will not get ItemsAdd. You can check that flag in the UI, see Tools | Options | Preferences | E-mail Options in the UI of Outlook 2007. Also, you can find that value in the registry, see SaveSent in HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Outlook\Preferences; I suppose replacing 12 with corresponding figures is required if you deal with other Outlook versions.

As to getting ItemAdd, see Step 13. Handling events of Outlook Items object in http://www.add-in-express.com/docs/net-outlook-addins.php. Both C# asn VB versions of that sample add-in project can be downloaded on the http://www.add-in-express.com/downloads/adxnet.php.


Andrei Smolin
Add-in Express Team Leader
Posted 27 Jul, 2010 05:05:48 Top
Dennis Smit




Posts: 9
Joined: 2010-05-13
Thanks for your reply, I will investigate this. You agree that this is the right way to get the sender email address while sending an email, or do you have another suggestion?

Thanks in advance!
Posted 27 Jul, 2010 09:07:28 Top
Andrei Smolin


Add-in Express team


Posts: 18829
Joined: 2006-05-11
Hi Dennis,

If supporting Outlook 2007+ only, I'd also try using MailItem.SendUsingAccount and then Account.SmtpAddress.


Andrei Smolin
Add-in Express Team Leader
Posted 27 Jul, 2010 09:24:54 Top
Dennis Smit




Posts: 9
Joined: 2010-05-13
Thanks for your response, support is needed for 2003,2007 and 2010, so I think I should stick to
the itemsadd event in the sent folder, right?

I'll make a nice drag in component that does all the wiring automatically and post that here when it is done!
Posted 27 Jul, 2010 16:19:13 Top
Andrei Smolin


Add-in Express team


Posts: 18829
Joined: 2006-05-11
Hi Dennis,

Okay. Don't hesitate to ask for help if you need it.


Andrei Smolin
Add-in Express Team Leader
Posted 28 Jul, 2010 07:13:18 Top