CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 1999
    Location
    G day Mayt Land
    Posts
    971

    Talking Outlook and logon

    in a code i mtrying to logon to outlook and get al te contacts details.
    Code:
                Outlook.Application oApp = new Outlook.Application();
                Outlook.NameSpace oNS = oApp.GetNamespace("mapi");
                oNS.Logon("", null, null, null);
                Outlook.MAPIFolder oContacts = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts);
                
                Outlook.Items oItems = (Outlook.Items)oContacts.Items;
                int i = oItems.Count;
                if (i > 0)
                {
                    Outlook.ContactItem oCt = (Outlook.ContactItem)oItems.GetFirst();
                    while (i > 0)
                    {
                        string temp = oCt.FullName.ToString();
                        oCt = (Outlook.ContactItem)oItems.GetNext();
                        string s = temp;
                        i--;
                    }
                }
                oNS.Logoff();
    for some reason i am getting zero counts for i and that may have to do with the logon statement.
    I have also done it with providing the userid and password and no luck so far , so my question is how do you know if you are actullay logged on or not ?

    should not what i have codeed in logon statement pop up a dialog asking me to logon?

  2. #2
    Join Date
    Sep 2000
    Location
    FL
    Posts
    1,452

    Re: Outlook and logon

    I think you are going to need at least a profile name. I use this in some of my .net code.

    Code:
                ONS.Logon("MyProfileName", "MyPassword", true, true);
    This is for a windows active directory domain and outlook 2007 connected to MS Exchange.

    I am not exactly sure but you will probably end up with several message boxes asking if you want to allow access to your contacts.

    Good luck.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured