Solved

VB Script in Outlook 2010 user name

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Check out this infographic on what you need to make a good email signature that will work perfectly for your organization.
Sometimes Outlook might have problems sending a message. There may be various causes- corrupted PST, AV scanner etc. The message, instead of going to the Sent Items folder, sits in the Outbox indefinitely. To remove it you can use a free tool cal…
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…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

762 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

18 Experts available now in Live!

Get 1:1 Help Now