Results 1 to 15 of 15

Display name of outlook current user via excel-VBA

Threaded View

  1. #1
    Registered User
    Join Date
    01-09-2011
    Location
    Santiago, Chile
    MS-Off Ver
    Excel 2003
    Posts
    51

    Display name of outlook current user via excel-VBA

    Hello! I'm trying to find the name of the current user of outlook.
    I'm writing an automated email via excel-VBA, and at the end of the email, I want to write the name of the current user.

    I've tried this:

    Sub name()
    Dim username As String, Ln As Long
    Set wn = CreateObject("Wscript.Network")
    username = WshNetwork.username
    MsgBox (username)
    
    End Sub
    But I only get the user name of windows..

    And then I tried this:
    Sub username()
    
    Set objSession = CreateObject("MAPI.Session")
    
    ' Logon using an existing MAPI session
    objSession.Logon "", "", False, False, 0
    
    ' Get folder where the current Outlook item lives
    Set objFolder = Item.Parent
    
    ' Get the Outlook item with CDO
    Set objMessage = objSession.GetMessage(Item.EntryID, objFolder.StoreID)
    
    ' Get the sender of the message
    Set objSender = objMessage.Sender
    
    ' Pull out some properties of the sender
    MsgBox ("Sender name: " & objSender.Name)
    MsgBox ("Sender address: " & objSender.Address)
    
    ' Close MAPI session
    objSession.Logoff
    
    End Sub
    But a big error appears ([colaboration data objects - [MAPI_E_LOGON_FAILED(80040111)])

    Is there a simplified way for dummies? Thank you in advance
    Last edited by Alicita; 02-15-2011 at 08:12 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1