Richard Plana
Posts: 5
Joined: 2007-01-10
|
Could I get advice on how to acquire the sender's (account) email address whenever a new email is being composed (regardless of whether the default account is being used or not)? I would prefer a solution in this order of preference: Outlook Object Model, ADX, Redemption, CDO and Extended MAPI. |
|
Sergey Grischenko
Add-in Express team
Posts: 7235
Joined: 2004-07-05
|
|
Esteban Astudillo
Guest
|
Hi Sergey,
I compiled and ran this example but I always get an empty email address in the dialog box.
Is you solution designed to work with Exchange accounts? I have tried it only in one machine where I have both POP and Exchange accounts and when I get the same result when I choose one type of account or the other in the Accounts list (POP/Ex)
I will try with another machine configure to only use POP3, but before that I wanted to confirm with you when I can expect this solution to work.
In my dev machine where I tested this I'm using Outlook 2003 and your test solution was created with VS2005. I'm using ADX.net 3.2
Thanks in advance
Esteban |
|
Sergey Grischenko
Add-in Express team
Posts: 7235
Joined: 2004-07-05
|
Hi Esteban.
The project works with Exchange but the Exchange account should be the default account.
|
|
Esteban Astudillo
Guest
|
Hi Sergey,
When I tested this the Exchange account was in fact the default account. I also tried changing this but got the same results. I have 4 accounts in Outlook: 1 Exchange, 3 POP3.
Anyway, looking at the source code I noticed that the execution is always following the same path. If I understand this correctly, your code is trying to do this (please confirm):
- Get the value of the MailItem's PR_NEWMESSAGE_SENDER_EMAIL_ADDRESS MAPI property
- If that is empty:
- Load Accounts from registry
- Return the first one in the list
In my case the PR_NEWMESSAGE_SENDER_EMAIL_ADDRESS property is always empty, so the code is always getting the Accounts information and returning the first one, which in practice it's equivalent to use the default account information in Outlook, right?
In fact, that's exactly what I get: the default account's email address, not the account used when composing the message. For example, if I set the default account in Outlook to the Exchange account I get that account name back in the ItemSend event no matter what I choose in the Accounts drop down list in the Inspector window. Same behaviour if I set one of the POP3 accounts as the default one.
Is this the expected behaviour or am I still missing something?
Thank you in advance for straighten this up for me
Esteban
PS: I found a small bug in your sample code with the two SortedList private members of the Accounts class. Let me know if you need to know more about this. |
|
Sergey Grischenko
Add-in Express team
Posts: 7235
Joined: 2004-07-05
|
Hi Esteban.
For some reason I can't reproduce the issue. I have two accounts POP3 and one of the Exchange account. I always see the sender's address.
One more thing. The 'PR_NEWMESSAGE_SENDER_EMAIL_ADDRESS' constant is not a documented tag. So I can't guaranty that the code will 100% work in Outlook with mixed accounts. Now I don't have any other solution for this issue. |
|