Solved

Reading the sender of an email's address

Posted on 2000-02-29
6
240 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 100 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

717 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