Use Redemption to get sender's email address

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 (e-mail address removed). 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;




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 (e-mail address removed). How do I get the sender address?
(mail is Outlook mailitem).



Thanks,



Danny Huang
 
B

BVM

Thanks, it works better.
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;

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


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 (e-mail address removed). 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.




Thanks, it works better.
 

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