Solved

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

Posted on 2014-01-20
6
691 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 48

Expert Comment

by:Rgonzo1971
Comment Utility
Hi,


Have you tried ?

objMail.SenderEmailAddress

or maybe

objMail.Sender.Address


Regards
0
 
LVL 13

Expert Comment

by:frankhelk
Comment Utility
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
Comment Utility
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 48

Assisted Solution

by:Rgonzo1971
Rgonzo1971 earned 250 total points
Comment Utility
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 13

Accepted Solution

by:
frankhelk earned 250 total points
Comment Utility
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
Comment Utility
Thanks
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

762 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

12 Experts available now in Live!

Get 1:1 Help Now