VB Script in Outlook 2010 user name

Hello,

Currently, I programatically get the user name from the Outlook 2003 Mailbox like this:

  t = oNS.GetDefaultFolder(6).Parent.Name '6=olFolderInbox Parent = MailBox Folder Name
  If Left(t, 7) = "E-mail " Then t = Trim(Mid(t, 8))
  If Left(t, 8) = "Mailbox" Then t = Trim(Mid(t, 8))
' t = Mid(t, Instr(t, "-") + 1)     'Parse out the user's name from the Mailbox Folder Name
  iPos = 0: iPos = InstrRev(t, "-")
  If iPos > 0 Then
    t = Mid(t, iPos + 1)    'Parse out the user's name from the Mailbox Folder Name
  End If
  t = Replace(t, "[","")
  t = Replace(t, "]","")
  t = Trim(t)

This code would return something like "John Smith".  However, since upgrading to Outlook 2010, it returns this: "johns@abc.com".  I need to find another field name or something to get the actual users name.

Thanks,
Joel
Genius123Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
mvidasConnect With a Mentor Commented:
Hi Joel,

What about using the namespace's session name directly?
MsgBox oNS.Session.CurrentUser

Open in new window

Matt
0
 
Genius123Author Commented:
Brilliant!  That worked!  Thanks.
0
All Courses

From novice to tech pro — start learning today.