Use Redemption to get sender's email address

  • Thread starter BVM
  • Start date Views 4,323
Status
Not open for further replies.
B

BVM

Hi:

I can get recipient's email by using Redemption:

Redemption.MAPIUtils utils = new Redemption.MAPIUtils();

utils.MAPIOBJECT = this.Application.Session.MAPIOBJECT;

int PrSMTPAddress = 0x39FE001E;

string AddresseeEmail = (string)utils.HrGetOneProp(mail.Recipients[1].AddressEntry.MAPIOBJECT, PrSMTPAddress);

Now I want to get sender's email address as well. mail.SenderEmailAddress is not always as simple as xxx@xxx.com. How do I get the sender address? (mail is Outlook mailitem).

Thanks,

Danny Huang
 
K

Ken Slovak - [MVP - Outlook]

Instead of using the MAPIUtils object I'd recommend using an RDOMail object

for both tasks. You need an RDOSession object for that of course but I think

that's the better approach:

Redemption.RDOSession session = new Redemption.RDOSesison;

session.MAPIOBJECT = this.Application.Session.MAPIOBJECT;

// _missing is System.Reflection.Missing.Value, olMail is the Outlook mail

item

Redemption.RDOMail _mail = session.GetMessageFromID(olMail.EntryID,

_missing, _missing);

string recipEmail = _mail.Recipients[1].AddressEntry.SMTPAddress;

string senderEmail = _mail.Sender.SMTPAddress;

"BVM" <DennisH@TBH.com.au> wrote in message

news:u$Q%23QimuKHA.4636@TK2MSFTNGP06.phx.gbl...

Hi:

I can get recipient's email by using Redemption:

Redemption.MAPIUtils utils = new Redemption.MAPIUtils();

utils.MAPIOBJECT = this.Application.Session.MAPIOBJECT;

int PrSMTPAddress = 0x39FE001E;

string AddresseeEmail =

(string)utils.HrGetOneProp(mail.Recipients[1].AddressEntry.MAPIOBJECT,

PrSMTPAddress);

Now I want to get sender's email address as well. mail.SenderEmailAddress

is not always as simple as xxx@xxx.com. How do I get the sender address?

(mail is Outlook mailitem).

Thanks,

Danny Huang
 
B

BVM

Thanks, it works better.
<kenslovak@mvps.org> wrote in message news:Oc0FJkuuKHA.3408@TK2MSFTNGP06.phx.gbl...

Instead of using the MAPIUtils object I'd recommend using an RDOMail object for both tasks. You need an RDOSession object for that of course but I think that's the better approach:

Redemption.RDOSession session = new Redemption.RDOSesison;

session.MAPIOBJECT = this.Application.Session.MAPIOBJECT;

// _missing is System.Reflection.Missing.Value, olMail is the Outlook mail item

Redemption.RDOMail _mail = session.GetMessageFromID(olMail.EntryID, _missing, _missing);

string recipEmail = _mail.Recipients[1].AddressEntry.SMTPAddress;

string senderEmail = _mail.Sender.SMTPAddress;

"BVM" <DennisH@TBH.com.au> wrote in message news:u$Q%23QimuKHA.4636@TK2MSFTNGP06.phx.gbl...

Hi:

I can get recipient's email by using Redemption:

Redemption.MAPIUtils utils = new Redemption.MAPIUtils();

utils.MAPIOBJECT = this.Application.Session.MAPIOBJECT;

int PrSMTPAddress = 0x39FE001E;

string AddresseeEmail = (string)utils.HrGetOneProp(mail.Recipients[1].AddressEntry.MAPIOBJECT, PrSMTPAddress);

Now I want to get sender's email address as well. mail.SenderEmailAddress is not always as simple as xxx@xxx.com. How do I get the sender address? (mail is Outlook mailitem).

Thanks,

Danny Huang
 
K

Ken Slovak - [MVP - Outlook]

Although that was the lazy coder way. If the code will run in a loop or

where you need to release things as needed you're better off breaking this

line with all the dot operators into component parts with explicit objects

you can deterministically release as needed:

_mail.Recipients[1].AddressEntry.SMTPAddress

You'd instantiate explicit RDORecipients, RDORecipient and RDOAddressEntry

objects.

"BVM" <DennisH@TBH.com.au> wrote in message

news:u58jvOyuKHA.5316@TK2MSFTNGP05.phx.gbl...

Thanks, it works better.
 
Status
Not open for further replies.
Top