Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 747
  • Last Modified:

Can I programmatically read an email address from a mail object?

Hello,

I wrote a routine is VB that reads mail that arrives in my MS Outlook 2K Inbox.  I'm able to  loop through the items collection and read the message subject and body, however, I can not read the email address of emails that are received in my Inbox.

For example:

Global objInbox As MAPIFolder

       For n = objInbox.Items.Count To 1 Step -1              
                    Set objMail = objFolder.Items(n)
                    strSubject=objMail.subject
                    strBody=ojbMail.body
                    strSendersEmailAddress=????
'yada yada

       Next

I've done some research and suspect that only the displayname is accessible when Outlook 2K is used.  Can this be correct?  Reading the senders email address seems like it should be a pretty basic thing to do.

Please help!
0
pcalabria
Asked:
pcalabria
  • 2
  • 2
  • 2
2 Solutions
 
Rgonzo1971Commented:
Hi,


Have you tried ?

objMail.SenderEmailAddress

or maybe

objMail.Sender.Address


Regards
0
 
frankhelkCommented:
How about this:

I have set up an Outlook filter that acts on certain incoming mail (depending on the sender, to be precise - you might set it to react on every message), it gets the message object as attached item. Im the shown code I save the attachmants to a folder after displaying Sender Address and subject in an message box.
Public Sub SaveAttachments(Item As Outlook.MailItem)

    MsgBox (Item.SenderEmailAddress + vbCrLf + Item.Subject)
    
    For Each att In Item.Attachments
    
        att.SaveAsFile ("D:\Temp\" + att.FileName)
    
    Next

End Sub

Open in new window

0
 
pcalabriaAuthor Commented:
Thanks to both of you, however, this does not work.
The problem is that Outlook 2000 does not seem to support the SenderEmailAddress.

From the Immediate window....

?objmail.Subject
Returned mail: see transcript for details

?objmail.SenderName
Mail Delivery Subsystem

?objmail.senderEmailaddress
Returns an Error

?objmail.sender.address
Returns and Error.

We still have Outlook 2000 installed on the workstations because the code we use to send emails will not work with later versions of Outlook.  We will be forced to update at some point, however, for now, we are stuck with Outlook 2K.
0
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 
Rgonzo1971Commented:
HI,

pls refer to (with CDO)

http://www.outlookcode.com/d/code/getsenderaddy.htm

and refer to http://support.microsoft.com/kb/171440

to find CDO

Regards
0
 
frankhelkCommented:
There's another way to access the properties of a message, I don't have ready-to-use code at hand, but maybe these links could point you into the right direction:

Ways to access the properties (just for some other piece of data ... but the way is the same):


And some ressources to find the proper property codes and more access code:



Hope it helps ....
0
 
pcalabriaAuthor Commented:
Thanks
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now