Function MyEmail() Dim strEmail, strUserName Dim wmi, wsh On Error Resume Next 'Get user name (login name) Set wsh = CreateObject("Wscript.Shell") strUserName = wsh.ExpandEnvironmentStrings("%USERNAME%") 'Get email Set wmi = GetObject("winMgmts:root\directory\LDAP") If Err.Number <> 0 Then MyEmail = "" Exit Function End If 'Get the WMI user collection Set colUsers = wmi.ExecQuery("SELECT * FROM DS_User WHERE DS_samAccountName='" & strUserName & "'") If Err.Number <> 0 Then MyEmail = "" Exit Function End If 'Get the email address strEmail = "" For Each oUser In colUsers strEmail = oUser.Properties_("DS_mail") Next MyEmail = strEmail End Function