Solved

VB Script in Outlook 2010 user name

Posted on 2014-02-05
2
398 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…

770 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