![]() |
|
||||||||
| Site Links |
| Consulting |
| Knowledge Base |
| Training |
| Forum |
| Articles |
| Resources |
| Products |
| Cool Tools |
| Contact |
| About Us |
| Go to Page... |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
|
Is there a way, using VBA or otherwise, to get the email address a email was sent to?
I have multiple email addresses that all arrive in the same account, and sometimes I would like to know which address was used. (This is particularly relevant where I have been BCC'd, but there are other circumstances also.) Does anyone know a way to do this? ![]() (Just to make it more interesting, I would particularly like to do this from Excel, so I can list all emails sent to me using a particular address. Also, I occasionally get duplicate emails where more than one of my addresses is in the distribution list, so I would like to be able to distinguish which one was sent to which address.) |
|
Local Time: 11:26 AM
Local Date: 05-24-2013 Location:
|
|
|
|
#2 |
|
|
This should get you started. Paste the following code into a standard module in an Excel workbook VB project:
VBA:
VBA tags courtesy of www.thecodenet.com
The message field containing the recipient email address is the CdoPR_RECEIVED_BY_EMAIL_ADDRESS field (column D in the code). In my tests, this contains the recipient email address whether the sender sent the email to that address as the 'To:' address or the 'Bcc:' address. I've added a few more columns/CDO fields such as Sender and Subject to the Excel output to give more details for each email. |
|
Local Time: 01:26 PM
Local Date: 05-24-2013 |
|
|
|
#3 |
|
|
Thank you for this code - it look likes what I want, but when I tried it I get a compilation error.
I have referenced to Microsoft Outlook 14.0 Object Library and Microsoft CDO for Windows 2000 Library (the only Microsoft CDO in the list, location C:\Windows\SysWOW64\cdosys.dll). When I try to run the code, it goes to the top line of the function and gives the message "Compile Error: User-defined type not defined". Any ideas? It does not seem to like the following types: CdoPropTags, Fields, Field or Session |
|
Local Time: 11:26 AM
Local Date: 05-24-2013 Location:
|
|
|
|
#4 |
|
|
The code uses CDO 1.21 (CDO.DLL), which you can download from http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=3671
|
|
Local Time: 01:26 PM
Local Date: 05-24-2013 |
|
|
|
#5 |
|
|
When I try to install this, it says that it cannot be installed unless Microsoft Office Outlook 2007 is also installed.
I have Outlook 2010. Is there anything I can do? |
|
Local Time: 11:26 AM
Local Date: 05-24-2013 Location:
|
|
|
|
#6 |
|
|
Try installing the Office Compatibility Pack.
|
|
Local Time: 01:26 PM
Local Date: 05-24-2013 |
|
|
|
#7 |
|
|
The Compatability Pack is to allow you to use later versions, not earlier versions, isn't it?
I found on the MS website "CDO 1.2.1 is not supported for use with Outlook 2010. Most of the CDO 1.2.1 functionality has been incorporated into the Outlook 2010 object model", but no clue as to how to do this! |
|
Local Time: 11:26 AM
Local Date: 05-24-2013 Location:
|
|
|
|
#8 | |||||||||||||||||||||||
|
|
Ah yes, I think you are correct. When I was researching answers to your question 3 weeks ago I came across code on 2 web pages which might work for you. I didn't try them because I have Office 2003 and didn't know you have 2010 at that time. Luckily the 2 pages are still in my browser history: Outlook VBA Script that gets info on currently selected email using various Property Syntaxes (DASL) Outlook VBA Script that gets info on currently selected email using Property Tag Syntax The key to both scripts is the use of Outlook.PropertyAccessor, which is only available in Outlook 2007 and later, so I can't test it. The line in the 2nd piece of code which is relevant to your question is: VBA:
VBA tags courtesy of www.thecodenet.com
|
|||||||||||||||||||||||
|
Local Time: 01:26 PM
Local Date: 05-24-2013 |
|
![]() |
| Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|


