Logon method of the Outlook NameSpace Object

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Manuel

    Logon method of the Outlook NameSpace Object

    Hi,

    Using the PIA "Microsoft Outlook 11 Object Library".
    I've noticed that the Logon method of the NameSpace Object is simply ignored.

    My Outlook 2003 is full updated.

    For example if I write:

    Dim oApp As New Outlook.Applica tion
    Dim oNs As Outlook.NameSpa ce = oApp.GetNamespa ce("mapi")
    oNs.Logon("Outl ook", "myPassword ", false, True)
    Dim oFolder As Outlook.MAPIFol der =
    oNs.GetDefaultF older(Outlook.O lDefaultFolders .olFolderContac ts)

    Please note that I'm using only one profile: Outlook and the password is:
    myPassword
    but the Logon method is ignored and a user request for the password is
    displayed.

    Thank you for your help

    Manuel
  • Peter Huang [MSFT]

    #2
    RE: Logon method of the Outlook NameSpace Object

    Hi Manuel,

    Can you describe how did you configurate your outlook profile?
    Did the outlook connect to the Exchange Server?
    If you start Outlook directly, will the password dialog pop up?

    Based on my test, my Outlook is opened to connect to the Exchange server,
    but I did not get prompt that I need input password.

    Also the code below will work without call the Logon method.
    Imports Outlook = Microsoft.Offic e.Interop.Outlo ok
    Module Module1
    Sub Main()
    Dim oApp As New Outlook.Applica tion
    Dim oNs As Outlook.NameSpa ce = oApp.GetNamespa ce("mapi")
    'oNs.Logon("Def ault Outlook", "myPassword ", False, True)
    Dim oFolder As Outlook.MAPIFol der =
    oNs.GetDefaultF older(Outlook.O lDefaultFolders .olFolderInbox)
    For i As Integer = 1 To 5
    Console.WriteLi ne(oFolder.Item s(i).Subject)
    Next
    oApp.Quit()
    End Sub
    End Module

    Also from the VBA help file, we did not recommend you use Password option.

    Show All

    Logon Method
    See AlsoApplies ToExampleSpecif icsLogs the user on to MAPI, obtaining a
    MAPI session.


    expression.Logo n(Profile, Password, ShowDialog, NewSession)
    expression An expression that returns a NameSpace object.

    Profile Optional Variant. The MAPI profile name, as a String, to use for
    the session.

    Password Optional Variant. The password (if any), as a String,
    associated with the profile. This parameter exists only for backwards
    compatibility and for security reasons, it is not recommended for use.
    Microsoft Oultook will prompt the user to specify a password in most system
    configurations. This is your logon password and should not be confused with
    PST passwords.

    ShowDialog Optional Variant. True to display the MAPI logon dialog box
    to allow the user to select a MAPI profile.


    NewSession Optional Variant. True to create a new Outlook session. Since
    multiple sessions cannot be created in Outlook, this parameter should be
    specified as True only if a session does not already exist.



    If you have any concern, please feel free to let me know.


    Best regards,

    Peter Huang

    Microsoft Online Community Support
    =============== =============== =============== =====
    When responding to posts, please "Reply to Group" via your newsreader so
    that others may learn and benefit from your issue.
    =============== =============== =============== =====
    This posting is provided "AS IS" with no warranties, and confers no rights.

    Comment

    • Manuel

      #3
      RE: Logon method of the Outlook NameSpace Object

      Hi Peter,

      Thank you for your helpful response.

      The Outlook is not connected to Exchange Server (for now)
      I'm using the default Outlook profile created during setup and I have only
      set a password to the personal folders.
      If I start Outlook directly the password dialog will pop up.

      Best regards,
      Manuel


      ""Peter Huang" [MSFT]" wrote:
      Hi Manuel,
      >
      Can you describe how did you configurate your outlook profile?
      Did the outlook connect to the Exchange Server?
      If you start Outlook directly, will the password dialog pop up?
      >
      Based on my test, my Outlook is opened to connect to the Exchange server,
      but I did not get prompt that I need input password.
      >
      Also the code below will work without call the Logon method.
      Imports Outlook = Microsoft.Offic e.Interop.Outlo ok
      Module Module1
      Sub Main()
      Dim oApp As New Outlook.Applica tion
      Dim oNs As Outlook.NameSpa ce = oApp.GetNamespa ce("mapi")
      'oNs.Logon("Def ault Outlook", "myPassword ", False, True)
      Dim oFolder As Outlook.MAPIFol der =
      oNs.GetDefaultF older(Outlook.O lDefaultFolders .olFolderInbox)
      For i As Integer = 1 To 5
      Console.WriteLi ne(oFolder.Item s(i).Subject)
      Next
      oApp.Quit()
      End Sub
      End Module
      >
      Also from the VBA help file, we did not recommend you use Password option.
      >
      Show All
      >
      Logon Method
      See AlsoApplies ToExampleSpecif icsLogs the user on to MAPI, obtaining a
      MAPI session.
      >
      >
      expression.Logo n(Profile, Password, ShowDialog, NewSession)
      expression An expression that returns a NameSpace object.
      >
      Profile Optional Variant. The MAPI profile name, as a String, to use for
      the session.
      >
      Password Optional Variant. The password (if any), as a String,
      associated with the profile. This parameter exists only for backwards
      compatibility and for security reasons, it is not recommended for use.
      Microsoft Oultook will prompt the user to specify a password in most system
      configurations. This is your logon password and should not be confused with
      PST passwords.
      >
      ShowDialog Optional Variant. True to display the MAPI logon dialog box
      to allow the user to select a MAPI profile.
      >
      >
      NewSession Optional Variant. True to create a new Outlook session. Since
      multiple sessions cannot be created in Outlook, this parameter should be
      specified as True only if a session does not already exist.
      >
      >
      >
      If you have any concern, please feel free to let me know.
      >
      >
      Best regards,
      >
      Peter Huang
      >
      Microsoft Online Community Support
      =============== =============== =============== =====
      When responding to posts, please "Reply to Group" via your newsreader so
      that others may learn and benefit from your issue.
      =============== =============== =============== =====
      This posting is provided "AS IS" with no warranties, and confers no rights.
      >
      >

      Comment

      • Peter Huang [MSFT]

        #4
        RE: Logon method of the Outlook NameSpace Object

        Hi Manuel,

        The logon method is mainly working with Exchange environment as a MAPI
        session.
        Also if we check the document VBA Outlook help file
        C:\Program Files\Microsoft Office\OFFICE11 \1033\VBAOL11.C HM
        Password Optional Variant. The password (if any), as a String,
        associated with the profile. This parameter exists only for backwards
        compatibility and for security reasons, it is not recommended for use.
        Microsoft Oultook will prompt the user to specify a password in most
        system
        configurations. This is your logon password and should not be confused
        with
        PST passwords.
        NOTE the last sentence, the logon password is different from the PST
        passwords(i.e. the password you set for the Personal Folder which is linked
        to a local pst file)


        Best regards,

        Peter Huang

        Microsoft Online Community Support
        =============== =============== =============== =====
        When responding to posts, please "Reply to Group" via your newsreader so
        that others may learn and benefit from your issue.
        =============== =============== =============== =====
        This posting is provided "AS IS" with no warranties, and confers no rights.

        Comment

        • Manuel

          #5
          RE: Logon method of the Outlook NameSpace Object

          Hi Peter,

          It's clear.
          Thank you very much.

          Regards

          Manuel

          ""Peter Huang" [MSFT]" wrote:
          Hi Manuel,
          >
          The logon method is mainly working with Exchange environment as a MAPI
          session.
          Also if we check the document VBA Outlook help file
          C:\Program Files\Microsoft Office\OFFICE11 \1033\VBAOL11.C HM
          >
          Password Optional Variant. The password (if any), as a String,
          associated with the profile. This parameter exists only for backwards
          compatibility and for security reasons, it is not recommended for use.
          Microsoft Oultook will prompt the user to specify a password in most
          system
          configurations. This is your logon password and should not be confused
          with
          PST passwords.
          >
          NOTE the last sentence, the logon password is different from the PST
          passwords(i.e. the password you set for the Personal Folder which is linked
          to a local pst file)
          >
          >
          Best regards,
          >
          Peter Huang
          >
          Microsoft Online Community Support
          =============== =============== =============== =====
          When responding to posts, please "Reply to Group" via your newsreader so
          that others may learn and benefit from your issue.
          =============== =============== =============== =====
          This posting is provided "AS IS" with no warranties, and confers no rights.
          >
          >

          Comment

          • Peter Huang [MSFT]

            #6
            RE: Logon method of the Outlook NameSpace Object

            Hi Manuel,

            You are welcomed!
            If you have any other question, please feel free to post in the MSDN
            newsgroups.


            Best regards,

            Peter Huang

            Microsoft Online Community Support
            =============== =============== =============== =====
            When responding to posts, please "Reply to Group" via your newsreader so
            that others may learn and benefit from your issue.
            =============== =============== =============== =====
            This posting is provided "AS IS" with no warranties, and confers no rights.

            Comment

            • Tony Gravagno

              #7
              Re: Logon method of the Outlook NameSpace Object

              I am having similar issues to those described in this thread and I'd
              like to follow-up here. The problem is that at development time I
              don't know how the end-user has Outlook configured. Here are the
              scenarios I need to detect and accommodate:
              - User working from local PST, Outlook is not yet started.
              - User working from local PST, Outlook is open.
              - User working from Exchange Server, Outlook is not yet started.
              - User working from Exchange Server, Outlook is open.

              If the user is working with a PST then user/psw are null/nothing, and
              I may not even need to execute the Login - but how do I know this? At
              the moment I'm using a .config file, and if it contains a
              user/password then I use them to attempt a login. If not, I execute
              Login with null values. I'm still not sure under what condition I'd
              simply not attempt a .Login.

              And I'm not sure how I would detect if Outlook is already open, so
              that I would know whether to set the NewSession value to true or
              false. If I make the wrong choice it puts Outlook into a weird state,
              and the next time they open the application a dialog warns them that
              data may be corrupted and they may need to re-install Outlook. That's
              scary and not true. Closing and restarting Outlook clears this
              ScareUserFlag.

              Thanks!
              Tony
              MSDN Developer / Microsoft Partner


              v-phuang@online.m icrosoft.com ("Peter Huang" [MSFT]) wrote:
              >Hi Manuel,
              >
              >You are welcomed!
              >If you have any other question, please feel free to post in the MSDN
              >newsgroups.
              >
              >
              >Best regards,
              >
              >Peter Huang
              >
              >Microsoft Online Community Support

              Comment

              Working...