Link to home
Start Free TrialLog in
Avatar of nicolas_image
nicolas_image

asked on

Get sender email address Outlook.MailItem

How do I find the sender email?

I can get the sender name with the .SenderName property.  But how do I get the email address?

I am using the outlook.mailitem

Avatar of sdm395
sdm395

Try looking at the recipients collection of the mailitem.  Loop through until you find one with type = olOriginator - this will be the sender.  You can then use the .address property.

Hope this helps
Avatar of nicolas_image

ASKER

I have tried the following code:

- - - - - CUT - - - -
Set MailItem = oSelection.Item(Counter)
With MailItem
  If Not (.Recipients Is Nothing) Then
    Set RecipList = .Recipients
    For Each Recip In RecipList
      Select Case Recip.Type
        Case olTo
           msgbox "TO: " & Recip.adress
        Case olCC
           msgbox "CC: " & Recip.adress
        Case olBCC
           msgbox "BCC: " & Recip.adress
        Case olOriginator
           msgbox "From: " & Recip.adress
- - - - - CUT - - - - - -

But my code never display the MSGBOX "From:" WHY!!!


I have tried the following code:

- - - - - CUT - - - -
Set MailItem = oSelection.Item(Counter)
With MailItem
  If Not (.Recipients Is Nothing) Then
    Set RecipList = .Recipients
    For Each Recip In RecipList
      Select Case Recip.Type
        Case olTo
           msgbox "TO: " & Recip.adress
        Case olCC
           msgbox "CC: " & Recip.adress
        Case olBCC
           msgbox "BCC: " & Recip.adress
        Case olOriginator
           msgbox "From: " & Recip.adress
- - - - - CUT - - - - - -

But my code never display the MSGBOX "From:" WHY!!!


ASKER CERTIFIED SOLUTION
Avatar of sdm395
sdm395

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
OK thanks. Now I found it to.  Looks like MS has a small improvement to make here.