Outlook add-In -> how to get Sender SMTP Address  
Author Message
PolkaDance





PostPosted: Visual C# General, Outlook add-In -> how to get Sender SMTP Address Top

Hi,

I'm trying to make an add-in for outlook and I need to grab the Sender Address; I'm using

Microsoft.Office.Interop.Outlook.MailItem which has a SenderEmailAddress Property but when it comes from Exchange, it gives somethign like that:

/O=ANALYSTIK/OU=FIRST ADMINISTRATIVE GROUP/CN=RECIPIENTS/CN=EPLANTE

I have a book that talk about CDO using reflexivity but the example tells how to grab the subject but I don't need CDO for that! The MailItem object has it.

On the net I found an example in VBNet that uses this method:

Public Const CdoPR_EMAIL = &H39FE001E

string o = (String)objSession.GetAddressEntry(strAddressEntryID).Fields(CdoPR_EMAIL).Value

But GetAddressEntry doesn't give a result that has Fields.

 

I have a MailItem and I can get a MAPI.Message, from there can anyone tell me how to get the Sender SMTP address

Thanks



Visual C#8  
 
 
Felan





PostPosted: Visual C# General, Outlook add-In -> how to get Sender SMTP Address Top

I've used WebDAV to pull messages and I'm familiar with Exchange and Active Directory but I haven't used the method you are using.

That address you have there looks like an x500 address.  If you have windows 2003 admin tools install and use this query (with correct dc's):

dsquery * "dc=blah,dc=com" -filter "(samaccountname=yourLogonName)" -attr proxyaddresses

You will get one long string of semicolon-seperated emails with the type then a colon and the address (some of the addresses themselves will have semicolons).  Some of the addresses are internal to Exchange unlike the more user-friendly SMTP address.   In fact those x500 addresses can be a source of headaches with user created distribution lists for example where the x400 or x500 address has changed on the servers but the user's Outlook custom distribution list is unaware of this change.

In active directory code when you ask for this data it will be an array of addresses.

So I'm guessing that when you ask for that SenderEmailAddress property there might actually several values and its just giving you the first of several possibilities.


 
 
PolkaDance





PostPosted: Visual C# General, Outlook add-In -> how to get Sender SMTP Address Top

I'm sorry but I don't understand anything of what you wrote. I am using Windows Xp and using this command gives a batch error.

Anyway, All I need is to be able to grab the real email address from a MailItem that my add-in uses when an email comes into the inbox. It shouldn't be that complicated, even the To property doesn't give the true email address, what's up with this useless informatio, Microsoft dev didn't finish their job correctly or what

One of my collegue used ActiveDirectory but it wasn't working for 100% of what SenderEmailAddress was giving. 

Regards


 
 
Felan





PostPosted: Visual C# General, Outlook add-In -> how to get Sender SMTP Address Top

Your question would probably be better directed to the Microsoft Visual Studio Tools for the Microsoft Office forum, which is what I'm understanding you are using.

Here is a link:
http://forums.microsoft.com/msdn/showforum.aspx forumid=16&siteid=1