Getting the senders SMTP address using redemption

J

Jorgen Due

Hi all

I have read about half the internet trying to solve this problem.

My problem is, on outlook 2003, how to get the smtp address from the sender og a email when the address returned is a x400 exchange address.

There are a lot of documentation on redemption and VB, but I use C# and have some problems porting the VB samples to C#

here are some of my code.:


string SMTPAddress = "";
int PrSMTPAddress = 0x39FE001E; // not in cache-mode

Outlook.MailItem mailItem = mail as outlook.MailItem;
Redemption.MAPIUtils mapiUtils = new Redemption.MAPIUtils();

if (mailItem.SenderEmailAddress != null)
{
SMTPAddress = mailItem.SenderEmailAddress.ToString();
if(SMTPAddress.StartsWith("/"))
{
SMTPAddress = (string)mapiUtils.HrGetOneProp(mailItem.Recipients[1].Addres sEntry.MAPIOBJECT, PrSMTPAddress);
//this returns my own SMTP address - not the sender!!!



I know that I am doing something wrong, but does anyone have a solution i would be a happy man - again.. :)

Best regards, jorgen
 
D

Dmitry Streblechenko

Use SafeMailItem.Sender.SmtpAddress
Be prepared to handle SafeMailItem.Sender == null

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top