How do I retrieve the currently logged on MAPI profile name? 
Author Message
 How do I retrieve the currently logged on MAPI profile name?

The subject says it all.

Thanx in advance,

Mike Matheny
Network Administrator
GCWDA



Mon, 13 Mar 2000 03:00:00 GMT  
 How do I retrieve the currently logged on MAPI profile name?

Quote:

>The subject says it all.

>Thanx in advance,

>Mike Matheny
>Network Administrator
>GCWDA


>The subject says it all.

>Thanx in advance,

>Mike Matheny
>Network Administrator
>GCWDA


Mike:

I did this in an app which had MAPI controls.
Basically I created a message with a unique subject line
and saved it in the inbox without sending it. I then did a
fetch to refresh my inbox, located that message and
determined who it came from ... i.e., me. It's slow and
kludgy, but it works.

Here's code for the WhoAmI Function. It assumes a form
with MAPI session and message controls; mpiMsgs and
mpiSession. It also assumes mpiSession is logged in and
mpiMsgs is linked to it.

Public Function WhoAmI() As String
'==============================================================
'Author:    Barry Seymour, QuickStart Technologies
'Notes:     There's no way to figure out who I'm logged in as. Thus, the method we use is to
'create a dummy message, save without sending, open it and read the message originator.
'This returns the display name, but also sets public form-level variables MyDisplayName and
'MyEmailAddress for this form.
'==============================================================

    Dim m As Control, iCtr As Integer, sTemp As String
    Set m = mpiMsgs
    On Local Error GoTo WhoAmIErr

    If m.MsgIndex = -1 Then
        MsgBox "An Error occurred in the 'WhoAmI' function. The frmMAPI.GetUserID function cannot create a dummy message since one is already being created.", vbExclamation
        Exit Function
    End If

    On Local Error GoTo 0
    m.Compose ' create a new message ------------------------------------------------
    m.MsgSubject = "Dummy Message"
    m.MsgNoteText = "This is a dummy message created by the XYZ Application. If you can see this message it was because XYZ could not or did not delete it automatically. If you see this message you can safely delete it."
    m.Save ' SAVE IT WITHOUT SENDING IT.

    m.FetchUnreadOnly = False
    m.Fetch

    For iCtr = 0 To m.MsgCount - 1
        m.MsgIndex = iCtr
        If m.MsgSubject = "Dummy Message" Then

                'these are my global variables
            MyEMailAddress = m.MsgOrigAddress
            MyDisplayName = m.MsgOrigDisplayName

            WhoAmI = m.MsgOrigDisplayName ' return value of the WhoAmI function

            m.Delete ' delete the dummy message
            Exit Function
        End If
    Next iCtr

    'if you get this far, it didn't work...

    On Local Error GoTo 0

Exit Function
WhoAmIErr:
    MsgBox "Error " & Err & " occurred in the frmMapi.WhoAmI() function: " & Err.Description
    Exit Function

End Function



Mon, 13 Mar 2000 03:00:00 GMT  
 How do I retrieve the currently logged on MAPI profile name?


Fri, 19 Jun 1992 00:00:00 GMT  
 How do I retrieve the currently logged on MAPI profile name?

Actually, I found this by experimentation:

Dim objSession As Object    ' Session object
Dim strProfileName as string

Sub MAPILogon
    Set objSession = CreateObject("MAPI.Session")
    objSession.Logon showdialog:=True 'Prompts for a profile to select
    strProfileName = objSession
End Sub

This works when you initiate a MAPI session from within your VB program.
However, if you already have a MAPI sessionID, such as Outlook running, I
still can't figure out how to get the currently loaded profile name.



Quote:
> The subject says it all.

> Thanx in advance,

> Mike Matheny
> Network Administrator
> GCWDA




Mon, 13 Mar 2000 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Finding the workstation name of a currently logged on user

2. retrieve name of currently executed function

3. MAPI Profile Name

4. Retrieving the profile name used by the current user in Outlook

5. How can I retrieve the currently logged in users FULL name?

6. How can I retrieve the currently logged in users FULL name?

7. MS Exchange: How can I get current profile name or login name using VB

8. How do I specify a MAPI Profile for the MAPI controls to log on with?

9. Which Users are currently logged into a database?

10. VBA - Create Outlook Profiles - Can it be done!

11. Finding the ID of the user currently logged-in on a Win 95 desktop

12. display properties of currently logged on user

 

 
Powered by phpBB® Forum Software