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.
Similar threads
Thread starter Title 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
L Checking Sender Email Address for trusted domain from list on intranet Outlook VBA and Custom Forms 4
F Forward incoming email with 4 embedded images in the body without original sender Outlook VBA and Custom Forms 22
R Capture Sender's Display name and Address Outlook VBA and Custom Forms 3
T Junk Email does not get added to the Blocked Sender List Using Outlook 0
M How create a Rule to filter sender's email with more that one @ sign Using Outlook 1
F Junk Email does not get added to the Blocked Sender List Using Outlook 4
U Outlook 2016 Outlook 2016 sender name Using Outlook 1
C Macro to extract sender name & subject line of incoming emails to single txt file Outlook VBA and Custom Forms 3
Terry Sullivan Sender's Name Doesn't Appear in the From Field on Outlook 365/IMAP Using Outlook 2
K Use VBA to find Sender and Recipient from Microsfot 365 Journaled Email Items Outlook VBA and Custom Forms 3
Terry Sullivan Sender Field Displays My E-Mail Address, Not My Name Using Outlook 1
J Autoreply email recieved from specific sender after deleting some text from body. Using Outlook 0
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

Similar threads

Top