Logging into Exchange programmatically with VB

Are there 3 steps to success for using VB to automatically and programatically log into an Exchange Srevre with a valid account and password?  

When tried, the login dialog is thrown indicating the correct login/domain but wants to know the password.

Below is the function in VB.  Apprciate any and all comments/help

Private Function ACMISLogon() As Boolean
    ACMISLogon = False
    ' Create Recordset Object named rsUnread

    ' If a session is already started,
    ' exit sub.
    If bnewsession = False Then
        If mpsSess.NewSession Then
            MsgBox "Session already established"
            Exit Function
        End If
    End If
    On Error GoTo errLogInFail
    With mpsSess
        .UserName = "XXXX"
        .Password = "cmc"
        .LogonUI = True ' Use the underlying email system's logon UI.
        .SignOn ' Signon method.
        ' If successful, return True
        ACMISLogon = True
        ' Set NewSession to True and set0
        ' variable flag to true
        .NewSession = True
        bnewsession = .NewSession
        mpmMess.SessionID = .SessionID ' You must set this before continuing.
        sbrMapi.Panels("SessID") = "ID = " & .SessionID ' Just so you can see the SessionID.
    End With
    On Error GoTo 0
    Exit Function
    Debug.Print Err.Number, Err.Description
    If Err.Number = 32003 Then
        MsgBox "Canceled Login"
        ACMISLogon = False
    End If
    Exit Function
End Function

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Without seeing the SigOn method, I would have to guess that the logon method is not grabing the correct profile or the dialog will always show because of LogonUI = True.

Logon properties are:


profileName - Is the friendly name of a profile given by a user.

profilePassword - Password to access the account

showDialog - Show logon UI

newSession - should this be a newSession

parentWindow - parent window that owns this session

NoMail - Used when writing a service.  Gives the ability to send but not receive.

ProfileInfo - The Exchange Server/Mailbox name you want to access.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.