April 25, 2000 10:58 AM

Showing the Sender's Email Address

Rating: (0)
Windows IT Pro
InstantDoc ID #8630
In this sixth installment of Outlook VBA on Demand, I want to deal with an annoyance—specifically, how Outlook doesn't always display a sender's full email address on a message in your Inbox folder. You'll learn two new skills: how to add a new field to Outlook items and folders and how to use Collaboration Data Objects (CDO) to determine the sender's email address.

CD...

ARTICLE TOOLS

You must be a paid Professional Member to access this entire article.

Already a Professional Member? Please log in now:

NOT A PROFESSIONAL MEMBER? YOU CHOOSE:

Monthly or Annual

Professional Membership

VIP Membership

Compare Member Benefits

Add a Comment

Is there an equivalent of this code but to ensure that the recipient's address is printed, for example if I print out an email I have sent (rather than one I have received) I want it to show not only the name of the recipient but also their email address.

Andy4/4/2007 9:41:45 AM


Question - Is there a way to trigger the code to run against mail you have already recieved?
I notice that if I (Exchange Server) recieve mail with Outlook closed the field is blank. I want to be able to step thru my inbox on demand.
Thanks.

Anonymous User 6/9/2005 6:44:41 PM


I have plugged in your code, and there is no error, but I don't see any changes. Is there any way you can obtein fromaddress and date received as an export file or something.

if you export file from outlook as an excel file you get from address, if you export outlook as an access mdb file you've got from as a name and received date.

so is there any way you can get these two informations - from address and received date in one shot?

thanks in advance

Anonymous User 2/25/2005 7:18:33 AM


I don't get it, I don't see any changes

Anonymous User 2/24/2005 3:04:57 PM


How about showing the recipient's e-mail address. Any ideas? Thank you - Julius

Anonymous User 1/13/2005 4:09:05 AM


Hi,
I used ur code but am not getting the email id, instead am getting a big string as below
"/O=WIPRO/OU=FIRST ADMINISTRATIVE GROUP/CN=RECIPIENTS/CN=DHEVEND"

Please help me in finding out a way to extract sender email id.

Gnana1/12/2005 4:04:48 AM


bullss off


Anonymous User 1/3/2005 4:10:12 AM


I kinda found an answer to my own question (see July 06, 2004 post). Instead of using the code on those sites, I did some string and array manipulation to extract the Microsoft Exchange address. It works for now but it may not be the best way to do this. Here's the code - you can modify it to suit your needs but if you do something interesting please post it here for myself and others.

Function SenderFromAddress(objMsg As MailItem) As String '
Dim strEntryID As String
Dim strStoreID As String
Dim objSession As MAPI.Session
Dim objCDOItem As MAPI.Message

' get EntryID and StoreID for message
strEntryID = objMsg.EntryID
strStoreID = objMsg.Parent.StoreID

' start CDO session
Set objSession = CreateObject("MAPI.Session")
objSession.Logon , , False, False

' pass item to CDO and get sender address
On Error Resume Next
Set objCDOItem = objSession.GetMessage(strEntryID, strStoreID)
SenderFromAddress = objCDOItem.Sender.Address

' Check to see if the address is a Microsoft Exchange email address
If Left(SenderFromAddress, 3) = "/o=" Then

' Local variables
Dim senderAddress() As String
Dim strLength As Integer
Dim i As Integer
Dim username() As String
Dim temp As Integer
Dim sendersEmail As String

' Get length of MS Exchange string
strLength = Len(SenderFromAddress)

' Parse thru the string and insert into array
For i = 0 To strLength
ReDim Preserve senderAddress(i)
senderAddress(i) = Mid$(SenderFromAddress, i, 1)
Next i

' Get to the username at the end of the string.
' I started from 55 because that is where the first letter of the username
' in my string started, yours might be different.
' Ubound(senderAddress) gets you to the index of the last letter in the username
' Finally extract the username and concatenate it into a string literal
For i = 55 To UBound(senderAddress)
Dim j As Integer
sendersEmail = sendersEmail + senderAddress(i)
Next i

' Create the full email address for display
SenderFromAddress = sendersEmail + "@yourdomain.com"

Set objSession = Nothing
Set objCDOItem = Nothing
End If
End Function

Ashish7/8/2004 9:23:36 AM


I am trying to extract the SMTP address from an email address that originates from an exchange server. I tried some of the options mentioned earlier but with no success. Can someone please help me! Thanks
PS. The code works perfect for regular SMTP addresses!

Ashish7/6/2004 10:08:09 AM


Suzie -- You can start Outlook VBA with Alt+F11. If you're new to Outlook VBA macros, these web pages should help you get started:

http://www.winnetmag.com/Articles/Index.cfm?ArticleID=21522&pg=1
http://www.outlookcode.com/d/vb.htm

Sue Mosher 6/14/2004 6:34:59 AM


You must log on before posting a comment.

Are you a new visitor? Register Here

windows server 2008 login scripts

I have 2 win2k8 servers one pdc and bdc. The domain is exampledom.com They are connected to 2 iscsi luns which replicate each other. We are running ac...222-96118

advertisement

GOOGLE LINKS
SPONSORED LINKS
FEATURED LINKS

White Papers

Your remote offices contain valuable electronic data – are they adequately protected? Learn how proven technologies can reliably and cost-effectively back up a branch office from a central location, in real time, to disk or tape, and even utilize existing backup solutions.

Downloads

PacketTrap IT is a comprehensive and affordable network management and application monitoring solution that solves problems associated with bandwidth, network and application performance, and connectivity. Gain insight into your network - try PacketTrapIT free for 21 days!

Web Seminars

IT administrators have to solve a myriad of problems. This web seminar outlines the ten most common systems management pains - including managing highly distributed systems and dealing with data theft/loss – and the best practices to address each.

eLearning Series

We bring the experts direct to you to share their real-world perspective and expertise. During each event, three sessions stream in real time, so you can learn, ask questions, and get solutions.
Upcoming event: Getting the Most with Exchange 2010 with Paul Robichaux

Subscribe to Windows IT Pro!

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.