Solved

Show AD Username in Outlook

Posted on 2014-03-21
7
848 Views
Last Modified: 2014-04-10
Does anyone know of a way to show a user's AD logon/username in Outlook? When I get an email from a user, I often will have to look up their username name.

If Outlook showed me that information, it would save quite a bit of searching every day. If it helps, I am running Outlook 2013 and Exchange 2007.
0
Comment
Question by:Joseph Moody
  • 4
  • 2
7 Comments
 
LVL 11

Expert Comment

by:Giladn
ID: 39945790
try this
http://www.howto-outlook.com/howto/viewsenderaddress.htm
there is no other way or option to change the address view..

Gilad
0
 
LVL 76

Expert Comment

by:David Lee
ID: 39946735
Hi, Jmoody10.

How about a macro that displays that information?  If a macro is acceptable, then I can post the code and instructions for using it.
0
 
LVL 22

Author Comment

by:Joseph Moody
ID: 39957078
A Macro would be probably work!
0
Free Webinar: AWS Backup & DR

Join our upcoming webinar with experts from AWS, CloudBerry Lab, and the Town of Edgartown IT to discuss best practices for simplifying online backup management and cutting costs.

 
LVL 76

Expert Comment

by:David Lee
ID: 39957237
The macro would look the username up and add it to a custom property.  You could then customize your view to show that property.  Keep in mind that this will only work for messages you receive from folks inside your organization.  It won't work for messages you receive from anyone outside of your organization.
0
 
LVL 76

Accepted Solution

by:
David Lee earned 500 total points
ID: 39958678
Here's my solution.  It works by looking up each message sender in Active Directory and retrieving their account name.  It then adds a user property called "Username" to that message and sets it to the account name.  You can then add a new column to your view to see the username field.

Follow these instructions to add the code to Outlook.

1.  Start Outlook
2.  Press ALT+F11 to open the Visual Basic Editor
3.  If not already expanded, expand Microsoft Office Outlook Objects and click on ThisOutlookSession
4.  Copy the code from the Code Snippet box and paste it into the right-hand pane of Outlook's VB Editor window
5.  Click the diskette icon on the toolbar to save the changes
6.  Close the VB Editor
7.  Click File and select Options
8.  Click Trust Center
9. Click the Trust Center Settings button
10. Click Macro Settings
11. Change Macro Settings to "Notifications for all macros"
12. Click OK
13. Click OK
14. Close Outlook
15. Start Outlook.  Outlook will display a dialog-box warning that ThisOutlookSession contains macros and asking if you want to allow them to run.  Say yes.

Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
    Dim arrEID As Variant, varEID As Variant, olkItm As Object, olkPrp As Object, olkExu As Object, strUsr As String
    On Error Resume Next
    arrEID = Split(EntryIDCollection, ",")
    For Each varEID In arrEID
        Set olkItm = Session.GetItemFromID(varEID)
        If olkItm.Class = olMail Then
            Set olkExu = olkItm.Sender.GetExchangeUser
            If TypeName(olkExu) = "Nothing" Then
                strUsr = "Unknown"
            Else
                strUsr = GetUsernameFromAlias(olkExu.Alias)
            End If
            Set olkPrp = olkItm.UserProperties.Add("Username", olText, True)
            olkPrp.value = strUsr
            olkItm.Save
            Set olkPrp = Nothing
        End If
    Next
    On Error GoTo 0
    Set olkItm = Nothing
    Set olkExu = Nothing
End Sub

Function GetUsernameFromAlias(strAls As String) As String
    Dim adoCon As Object, adoRec As Object, objDSE As Object, strDNC As String, strSrc As String
    Set objDSE = GetObject("LDAP://RootDSE")
    strDNC = objDSE.get("defaultnamingcontext")
    strSrc = "'LDAP://" & strDNC & "'"
    Set adoCon = CreateObject("ADODB.Connection")
    adoCon.Provider = "ADsDSOObject"
    adoCon.CursorLocation = 3
    adoCon.Open "ADSI"
    Set adoRec = adoCon.Execute("SELECT samAccountName FROM " & strSrc & " Where objectClass='user' AND objectCategory='Person' AND mailNickname='" & strAls & "'")
    If Not adoRec.BOF And Not adoRec.EOF Then
        GetUsernameFromAlias = adoRec.Fields("samAccountName").value
    Else
        GetUsernameFromAlias = "Not Found"
    End If
    adoRec.Close
    adoCon.Close
    Set adoRec = Nothing
    Set adoCon = Nothing
    Set objDSE = Nothing
End Function

Open in new window

0
 
LVL 22

Author Closing Comment

by:Joseph Moody
ID: 39992422
This is wonderful!!!
0
 
LVL 76

Expert Comment

by:David Lee
ID: 39992525
Cool.  I'm glad you like it.
0

Featured Post

Backup Solution for AWS

Read about how CloudBerry Backup fully integrates your backups with Amazon S3 and Amazon Glacier to provide military-grade encryption and dramatically cut storage costs on any platform.

Question has a verified solution.

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

This article explains how to install and use the NTBackup utility that comes with Windows Server.
Many people use more than one email account and so it becomes difficult for them to manage them when they use separate accounts,  so, in this article, I have shared an easy way to add Other Mail Accounts in your Google Inbox. It helps to combine all…
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…
how to add IIS SMTP to handle application/Scanner relays into office 365.

679 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