Solved

VB Script in Outlook 2010 user name

Posted on 2014-02-05
2
400 Views
Last Modified: 2014-02-05
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
0
Comment
Question by:Genius123
2 Comments
 
LVL 35

Accepted Solution

by:
mvidas earned 500 total points
ID: 39836474
Hi Joel,

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

Open in new window

Matt
0
 

Author Closing Comment

by:Genius123
ID: 39836731
Brilliant!  That worked!  Thanks.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Read this checklist to learn more about the 15 things you should never include in an email signature.
In this step by step procedure, you will come to know the details of creating an Outlook meeting in 2007, 2010, 2013 & 2016.
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

726 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