A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Sender Properties



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old July 5th 06, 08:16 PM posted to microsoft.public.outlook.program_vba
[email protected]
external usenet poster
 
Posts: 3
Default Sender Properties

Hello,

I need to programatically access some information about a sender of an
email in Outlook.

In Outlook itself, I can rigth-click on the message sender, click Add
to Contacts, and then, when I open this contact up from Contacts, I
have not only his name and email, but his phone number, company,
department, etc. and other info recieved through Exchange or some
header.

Well, I need that information and it seems that MailItem only provides
me access to SenderName and SenderEmailAddress.

Is there any way I can programmatically access that information i.e. is
their a DOM way to retrieve the info that you can get by the manual
method described above?

Thanks in advance,
elenev

Ads
  #2  
Old July 5th 06, 10:05 PM posted to microsoft.public.outlook.program_vba
Eric Legault [MVP - Outlook]
external usenet poster
 
Posts: 830
Default Sender Properties

Outlook doesn't maintain a direct programmatic link between the sender of an
e-mail and a possible Contact record that was previously created from that
sender. Your only choice is to use the sender's name or e-mail address with
the Restrict or Find method on a folder's Items collection (or the
AdvancedSearchObject) to retrieve an actual ContactItem object.

Here's a function for using the e-mail address to retrieve a Contact. Just
pass a previously instantiated MAPIFolder object that is stores the Contact
in question (you can use NameSpace.GetDefaultFolder to get the MAPIFolder
object for the default Contacts folder if you like).

Function GetContactByEmailAddress(email As String, ContactFolder As
Outlook.MAPIFolder) As ContactItem
Dim objItems As Outlook.Items, objRItems As Outlook.Items

Set objItems = ContactFolder.Items
Set objRItems = objItems.Restrict("[E-mail] = '" & email & "'")

If objRItems.Count = 0 Then Exit Function
Set GetContactByEmailAddress = objRItems.Item(1)
End Function

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


" wrote:

Hello,

I need to programatically access some information about a sender of an
email in Outlook.

In Outlook itself, I can rigth-click on the message sender, click Add
to Contacts, and then, when I open this contact up from Contacts, I
have not only his name and email, but his phone number, company,
department, etc. and other info recieved through Exchange or some
header.

Well, I need that information and it seems that MailItem only provides
me access to SenderName and SenderEmailAddress.

Is there any way I can programmatically access that information i.e. is
their a DOM way to retrieve the info that you can get by the manual
method described above?

Thanks in advance,
elenev


  #3  
Old July 5th 06, 10:32 PM posted to microsoft.public.outlook.program_vba
[email protected]
external usenet poster
 
Posts: 3
Default Sender Properties

Eric,

Thank you for your explanation. I am sure your code will prove very
useful.

However, I most likely do NOT yet have the contact in the default
Contacts folder. The only source for all of that information that I
have is the information that seems to have come with the email.

Example: I receive an email from John Doe, whom I do NOT have in my
Contacts folder. Since John Doe works for my company and is on our
exchange server, I can right-click his name in the email, manually add
him to Contacts or click on "Outlook Properties". If I do that, I can
see a lot of information about this contact which I did not have
previously such as Company, Department, Phone Number, Fax, etc.

This is the information I am after, not the details of a contact who
already exists in my Contacts folder.

Is this unrealistic?

Thanks again for all your help,
Vadim

  #4  
Old July 6th 06, 12:24 AM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Sender Properties

The information does not come with the e-mail itself. If the message was
sent from outside of your EX domain, the e-mail only has the sender's name
and address.
In case of EX, the message has the sender's entry id, which can be used to
open the corresponding GAL object which contains the properties that you
need.

On the low level (MAPI in C++ or Delphi), you will need to retrieve the
PR_SENDER_ENTRYID property from the message, then use it to call
IAddrBook::OpenEntry. You can them retrieve the PR_COMPANY_NAME,
PR_OFFICE_TELEPHONE_NUMBER, etc from the returned IMailUser object. Look at
the message with OutlookSpy - select the message, click Imessage button on
the OutlookSpy toolbar, select the PR_SENDER_ENTRYID property, RMB, select
IMAPISession::OpenEntry.

if you want to use a higher level API, you are pretty much limited to CDO
1.21 or Redemption, both of which expose the Sender property on the
messages. The address entry returned from the Sender property allows to use
the Fields() collection to retrieve various MAPI properties
(PR_COMPANY_NAME, etc).

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

wrote in message
oups.com...
Eric,

Thank you for your explanation. I am sure your code will prove very
useful.

However, I most likely do NOT yet have the contact in the default
Contacts folder. The only source for all of that information that I
have is the information that seems to have come with the email.

Example: I receive an email from John Doe, whom I do NOT have in my
Contacts folder. Since John Doe works for my company and is on our
exchange server, I can right-click his name in the email, manually add
him to Contacts or click on "Outlook Properties". If I do that, I can
see a lot of information about this contact which I did not have
previously such as Company, Department, Phone Number, Fax, etc.

This is the information I am after, not the details of a contact who
already exists in my Contacts folder.

Is this unrealistic?

Thanks again for all your help,
Vadim



  #5  
Old July 6th 06, 04:34 PM posted to microsoft.public.outlook.program_vba
[email protected]
external usenet poster
 
Posts: 3
Default Sender Properties

Thank you Dmitry,

I had a nagging suspicion that all of this information was not actually
sent in the header and was only available through some directory query
that Outlook just did for me.. What I was hoping for would've been way
too convenient for me and a hell of a network drag for everyone else...


I really don't have the ability to install CDO or Redemption on all of
the client computers and since I am integrating it with Access, I can't
use C++ or Java and work with low-level abstraction. I guess I'll just
stick to importing names and email addresses.

Again, Dmitry and Eric, thank you for your help. Best regards,
Vadim

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Picture properties in OE6 John Izzy Outlook Express 3 June 20th 06 09:48 PM
can i group emails by sender & by number of items for each sender baffled_by_tech Outlook - Using Contacts 2 March 5th 06 09:27 PM
Programming changes to XML properties Ray Jackson Outlook and VBA 1 February 7th 06 02:06 PM
Junk mail: How to create a button for "Add sender to blocked sender list" Nananana Outlook - General Queries 2 February 2nd 06 01:37 PM
Calendar properties?? Sue Mosher [MVP-Outlook] Outlook - Installation 0 January 20th 06 09:09 PM


All times are GMT +1. The time now is 08:28 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.