Use Redemption to get sender's email address

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.
Thread starter Similar threads Forum Replies Date
A Edit subject - and change conversationTopic - using VBA and redemption Outlook VBA and Custom Forms 2
N Redemption VBA basics...something's missing Using Outlook 0
D Redemption? Need rapid pull of Outlook Contacts, email + notes for VBA Using Outlook 1
J 64-bit version of Redemption? Outlook VBA and Custom Forms 2
E Redemption access AppointmentItem Label from outlook Outlook VBA and Custom Forms 6
E Redemption MAPI access(c#) Outlook VBA and Custom Forms 4
W Redemption::RDOMail.PrintOut() / DoAction(maPrint) not working Outlook VBA and Custom Forms 1
M EMail1Address and EMail1AddressType strangeness using Redemption Outlook VBA and Custom Forms 2
A Creating Redemption.MAPIUtils failed with Windows 7 x64 Outlook VBA and Custom Forms 5
D href tags does not result in the full url with Redemption Outlook VBA and Custom Forms 4
E Redemption Foldes.Add doesn't work Outlook VBA and Custom Forms 3
E Redemption Foldes.Add doesn't work Outlook VBA and Custom Forms 3
N Redemption.RDOSession logon() stops emails sending-they stay in Ou Outlook VBA and Custom Forms 3
E Should I switch to redemption Outlook VBA and Custom Forms 11
E Should I switch to redemption Outlook VBA and Custom Forms 11
C Redemption - Rules for outlook Outlook VBA and Custom Forms 1
G Error in Outlook Object Model with redemption and google apps prem Outlook VBA and Custom Forms 3
P Redemption Send EMail Outlook VBA and Custom Forms 10
S redemption reference Outlook VBA and Custom Forms 1
T Configure mailbox OutofOffice with Redemption Outlook Outlook VBA and Custom Forms 1
D redemption dll not registering in windows vista Outlook VBA and Custom Forms 3
Y Redemption MessageItem SaveAs problem Outlook VBA and Custom Forms 8
R Newbie Redemption ISafeMailItemPtr question Outlook VBA and Custom Forms 6
Q GAL.ResolveName issue with REDEMPTION Outlook VBA and Custom Forms 5
Q REDEMPTION HANGING during LOGON Outlook VBA and Custom Forms 2
P Redemption not working on OL2007 Outlook VBA and Custom Forms 2
P Redemption Send EMail fails Outlook VBA and Custom Forms 4
S delete appointmentitem permanently using redemption Outlook VBA and Custom Forms 2
D redemption - foldercreate event + delegate user Outlook VBA and Custom Forms 8
C Assign To and CC list while using Redemption.dll library Outlook VBA and Custom Forms 10
U Re: Read fields with Redemption Outlook VBA and Custom Forms 1
V redemption MAPIUtils Outlook VBA and Custom Forms 3
D Reply with a template loose the sender's embedded image Outlook VBA and Custom Forms 0
J Outlook 2016 How tell Outlook not to trust sender? Using Outlook 1
M Screen Scrape Sender IP Address Outlook VBA and Custom Forms 6
S Meeting Invite arrives from Wrong ("send-as") Sender Using Outlook 1
icacream Rule based on sender / wrong sender sent to folder Using Outlook 7
D Moving Emails Based on Recipient/Sender Outlook VBA and Custom Forms 4
B Looking to filter (or just find/search) for only messages that the sender has sent more than 1 messa Using Outlook 2
I How to display sender's name instead of email address in outlook 2013 message Using Outlook 5
A Sort emails into subfolders based on sender and deleting emails automatically Outlook VBA and Custom Forms 3
C Display Sender As Contact Outlook VBA and Custom Forms 4
Ed Sheehan Unusual behaviour in setting Sender (Outlook 2016) Outlook VBA and Custom Forms 4
J Auto Forward - Include Attachment and change Subject depending on original sender Outlook VBA and Custom Forms 3
Q Undisclosed recipients does not include sender Using Outlook 1
M Move new mail to folder based on sender address Outlook VBA and Custom Forms 2
D Inserting sender name and address with vba Outlook VBA and Custom Forms 1
M Blocked Sender List @Domain Not Working Using Outlook 0
P MS OUTLOOK 2013 - Adding Sender on the CC line Using Outlook 5
J Saving attachments from specific sender (phone number) to specific folder on hard drive Using Outlook 3
Similar threads


















































Top