?
Solved

Reading the sender of an email's address

Posted on 2000-02-29
6
Medium Priority
?
242 Views
Last Modified: 2010-05-18
I've written an office automation program that reads each message from Outlook 98 and filters them as necessary. It is finished except for one minor part. I cannot get the sender's email address 100% of the time, only about 80%.

I have looked through the entire message object on a email that doesn't give me its address (I can get the sender's name, but not the address).

Part of the code (relevant bits) is below, aswell as the statements I currently use to get the address (on the ones which have them).

-------------------------------

    Set dbMail = DBEngine(0).OpenDatabase("export.mdb")
   
    For Each msgOutlook In folderOutlook.Items
               
        If (msgOutlook.ReplyRecipientNames = "") Then
            strFROM = msgOutlook.SenderName
        Else
            strFROM = msgOutlook.ReplyRecipientNames
        End If

        'Rest of code

-------------------------------

'msgOutlook.ReplyRecipientNames' sometimes contain the address, otherwise I have to use 'msgOutlook.SenderName' which contains the name of the sender.

Anything I have missed that will get me the email address 100% of the time?


0
Comment
Question by:AdamWoodland
[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
  • 4
  • 2
6 Comments
 
LVL 15

Expert Comment

by:cquinn
ID: 2569665
I believe the way to do it is to create a reply (which you later destroy without sending it) and look at the address property of the reply object.
0
 
LVL 15

Accepted Solution

by:
cquinn earned 400 total points
ID: 2569869
I have investigated further, and the way I do it using CDO is to look at the .sender.address property.

Using the outlook object model, you would need to look at message.recipients(0).address property of the temporary reply object - something like

oReply=msgOutlook.reply
strfrom =oReply.Recipients(0).Address
0
 
LVL 2

Author Comment

by:AdamWoodland
ID: 2569903
Cheers, I'll give that reply a go tomorrow.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Author Comment

by:AdamWoodland
ID: 2571850
That seems to work for the messages that I couldn't get the address from (only the name), I used that in conjunction with my other code and between them it works 100% (so far, but I have to do some more testing).

Thanks again cquinn.

Adam
0
 
LVL 2

Author Comment

by:AdamWoodland
ID: 2571860
Oh yes - forgot to mention, your code should have been (in my case):

Set oReply = msgOutlook.Reply
strFROM = oReply.Recipients.Item(1).Address

:-)

Your suggestion helped, I only had to do a bit of tweaking.
0
 
LVL 2

Author Comment

by:AdamWoodland
ID: 2571867
That seems to work for the messages that I couldn't get the address from (only the name), I used that in conjunction with my other code and between them it works 100% (so far, but I have to do some more testing).

Thanks again cquinn.

Adam
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

752 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