Home All Groups Group Topic Archive Search About

Logon method of the Outlook NameSpace Object

Author
26 Oct 2006 3:41 PM
Manuel
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.Application
Dim oNs As Outlook.NameSpace = oApp.GetNamespace("mapi")
oNs.Logon("Outlook", "myPassword", false, True)
Dim oFolder As Outlook.MAPIFolder =
oNs.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts)

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

Author
27 Oct 2006 6:06 AM
Peter Huang" [MSFT]
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.Office.Interop.Outlook
Module Module1
    Sub Main()
        Dim oApp As New Outlook.Application
        Dim oNs As Outlook.NameSpace = oApp.GetNamespace("mapi")
        'oNs.Logon("Default Outlook", "myPassword", False, True)
        Dim oFolder As Outlook.MAPIFolder =
oNs.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
        For i As Integer = 1 To 5
            Console.WriteLine(oFolder.Items(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 ToExampleSpecificsLogs the user on to MAPI, obtaining a
MAPI session.


expression.Logon(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.
Author
27 Oct 2006 8:35 AM
Manuel
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


Show quoteHide quote
""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.Office.Interop.Outlook
> Module Module1
>     Sub Main()
>         Dim oApp As New Outlook.Application
>         Dim oNs As Outlook.NameSpace = oApp.GetNamespace("mapi")
>         'oNs.Logon("Default Outlook", "myPassword", False, True)
>         Dim oFolder As Outlook.MAPIFolder =
> oNs.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
>         For i As Integer = 1 To 5
>             Console.WriteLine(oFolder.Items(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 ToExampleSpecificsLogs the user on to MAPI, obtaining a
> MAPI session.
>
>
> expression.Logon(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.
>
>
Author
27 Oct 2006 9:16 AM
Peter Huang" [MSFT]
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.CHM

> 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.
Author
27 Oct 2006 10:19 AM
Manuel
Hi Peter,

It's clear.
Thank you very much.

Regards

Manuel

Show quoteHide quote
""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.CHM
>
> > 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.
>
>
Author
31 Oct 2006 3:06 AM
Peter Huang" [MSFT]
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.
Author
11 Nov 2006 12:33 AM
Tony Gravagno
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-phu***@online.microsoft.com ("Peter Huang" [MSFT]) wrote:

Show quoteHide quote
>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