Solved

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

Posted on 2014-01-20
6
700 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
  • 2
  • 2
  • 2
6 Comments
 
LVL 49

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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 49

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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

911 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now