Solved

Reading the sender of an email's address

Posted on 2000-02-29
6
233 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
  • 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
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.

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
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…

757 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