outlook 2000 - getting a mail's mail address 
Author Message
 outlook 2000 - getting a mail's mail address

I am writing an application, where one part of the application is written
using the Outlook 2000 object model and Visual Basic. The script is quite
small, and the task is simple: whenever a new mail arrives, get the senders
e-mail address, and process it in some way. The problem is, it seems to be
impossible to retrieve the e-mail address of the sender. Only the name is
available (mailItem.sender). However, it seems unreasonable to me if it is
not possible to get the address in some way. Anyone got a hint?

Thanks in advance,
Thorvald Boe

--
Posted from free.isi.no [193.216.57.66]
via Mailgate.ORG Server - http://www.*-*-*.com/



Fri, 19 Sep 2003 18:56:38 GMT  
 outlook 2000 - getting a mail's mail address

Quote:
> I am writing an application, where one part of the application is written
> using the Outlook 2000 object model and visual basic. The script is quite
> small, and the task is simple: whenever a new mail arrives, get the
senders
> e-mail address, and process it in some way. The problem is, it seems to be
> impossible to retrieve the e-mail address of the sender. Only the name is
> available (mailItem.sender). However, it seems unreasonable to me if it is
> not possible to get the address in some way. Anyone got a hint?

> Thanks in advance,
> Thorvald Boe

The following routine does the job bit requires a reference to Microsofts
CDO.dll . I posted a question about this myself last week but nobody knew
the answer. Finally found it in an obscure place on the net. The objMailItem
parameter is an Outlook mailitem object. I have tested this and it works
fine:

Private Function Sender_Address(objMsg As MailItem) As String
'-----------------------------
Dim strEntryID As String
Dim strStoreID As String
Dim objSession As MAPI.Session
Dim objCDOItem As MAPI.Message
'-----------------------------

On Error Resume Next

'------------------------------------
' get EntryID and StoreID for message
'------------------------------------
strEntryID = objMsg.EntryID
strStoreID = objMsg.Parent.StoreID

'------------------
' start CDO session
'------------------
Set objSession = CreateObject("MAPI.Session")
objSession.Logon , , False, False

'----------------------------------------
' pass item to CDO and get sender address
'----------------------------------------
Set objCDOItem = objSession.GetMessage(strEntryID, strStoreID)
Sender_Address = objCDOItem.Sender.Address

Set objSession = Nothing
Set objCDOItem = Nothing

End Function



Sat, 20 Sep 2003 04:45:42 GMT  
 outlook 2000 - getting a mail's mail address
Might want to check out www.slipstick.com, tons of examples


Sat, 20 Sep 2003 11:28:59 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Word 2000 Mail merge using Outlook address book

2. Sending an Outlook mail from my VBA-code doesn't close the mail windows

3. Specifying an e-mail address or Reply To address when sending mail

4. Mail server's address from Email address

5. E-mail security in Outlook 2000/XP blocks normal application development

6. Send Plain text mail with Outlook 2000

7. Sending an e-mail with Outlook 2000 from within Access

8. Using the Outlook 2000 VBA in Reveived mail

9. Limit on Mail-Recipients in Outlook 97/2000????

10. Outlook 2000: How to add an event handler to double click on a mail

11. Creating Plain Text E-Mails with Outlook 2000

12. Outlook 2000 / Parse body & forward mails

 

 
Powered by phpBB® Forum Software