Solved

Show AD Username in Outlook

Posted on 2014-03-21
7
748 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
Comment Utility
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
Comment Utility
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 21

Author Comment

by:Joseph Moody
Comment Utility
A Macro would be probably work!
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 76

Expert Comment

by:David Lee
Comment Utility
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
Comment Utility
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 21

Author Closing Comment

by:Joseph Moody
Comment Utility
This is wonderful!!!
0
 
LVL 76

Expert Comment

by:David Lee
Comment Utility
Cool.  I'm glad you like it.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

We are happy to announce a brand new addition to our line of acclaimed email signature management products – CodeTwo Email Signatures for Office 365.
Learn to move / copy / export exchange contacts to iPhone without using any software. Also see the issues in configuration of exchange with iPhone to migrate contacts.
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…
In this video we show how to create a mailbox database in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Servers >> Data…

744 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

14 Experts available now in Live!

Get 1:1 Help Now