Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to Read a sender address for MailItem (MS Outlook) Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
03-Jun-03
Category
OLE
Language
Delphi 2.x
Views
127
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Mike Shkolnik

How can I retrieve SenderAddress by SenderName?

Answer:

Sometime ago I posted a few tips for MS Outlook automation. I want to continue this 
serie. 

If you tried to work with messages from Delphi, you know that received message have 
the SenderName property (name of sender) but doesn't allow to read the real address 
of sender. Something like SenderAddress is not  available. 

Exists a few methods to retrieve this information: 

1. help file says that sender is in Recipients collection with Type property - 0 
(olOriginator). But this way is not work for any version of MS Outlook. So just 
iterate thru collection of Recipients and find an item with Type=0 couldn't return 
required value 

2. as alternative you can read a ReplyTo property - there you'll receive an address 
(but generally ReplyTo and Sender could be different). For example, in messages 
which I send from own mail account these values are 
different. 

3. to create a new MailItem (just will be destroyed without saving in end of work), 
define a Recipient as value which you received from SenderName of your original 
message and call a Resolve method - after that you'll recieve a correct email 
address of this sender. 

4. more correct and fast solution is the next: 

1   begin
2     objCDO := CreateOLEObject('MAPI.Session');
3     objCDO.Logon('', '', False, False);
4     objMsg := objCDO.GetMessage(itemOL.EntryID, itemOL.Parent.StoreID);
5   
6     s := objMsg.Sender.Address;
7     showmessage(s);
8     objMsg := UnAssigned;
9     objCDO := UnAssigned;
10  end


where itemOL is a MailItem which contain a SenderName but doesn't contain a SenderAddress:-) 

			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC