Solved

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

Posted on 2014-01-20
6
722 Views
Last Modified: 2014-02-27
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
Comment
Question by:pcalabria
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 51

Expert Comment

by:Rgonzo1971
ID: 39793896
Hi,


Have you tried ?

objMail.SenderEmailAddress

or maybe

objMail.Sender.Address


Regards
0
 
LVL 14

Expert Comment

by:frankhelk
ID: 39793972
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
 

Author Comment

by:pcalabria
ID: 39794518
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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 51

Assisted Solution

by:Rgonzo1971
Rgonzo1971 earned 250 total points
ID: 39794749
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
 
LVL 14

Accepted Solution

by:
frankhelk earned 250 total points
ID: 39797283
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
 

Author Closing Comment

by:pcalabria
ID: 39891979
Thanks
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question