-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: SitaramanM
Message 3 in Discussion

Hi   Check this out. U need to add the Outlook Interop Assembly Reference in ur 
project     static void Main(string[] args)
    {
     //
     // TODO: Add code to start application here
     //
     OutlookClient l_objOutClient=new OutlookClient();
     l_objOutClient.fnPrintOutlookContactsInfo();
  
    }
   }    class OutlookClient
   {
    public void fnPrintOutlookContactsInfo()
    {      // The following line was giving problems as per one of the posts in 
DotNetGeneral Forum
     // So commented it and used Outlook.ApplicationClass instead with proper 
typecasting
     // Outlook.Application l_objOutlookApp =new Outlook.Application();
     Outlook.ApplicationClass l_objOutlookApp =(Outlook.ApplicationClass) new 
Outlook.ApplicationClass();       Outlook.MAPIFolder cContacts; 
     Outlook.Items l_objContactItems; 
     Outlook.ContactItem l_objContactItem;
     int   l_intContactItemCtr ;
           
     // Get NameSpace. 
     Console.WriteLine((l_objOutlookApp.GetNamespace("mapi")).GetType()); // Gives 
"Outlook.NameSpaceClass"9
     //The following line was giving problems as per one of the posts in the 
DotNetGeneral Forum
     // So commented it and used Outlook.NameSpaceClass instead with proper typecasting
     //Outlook.NameSpace l_objOutlookNamespace = l_objOutlookApp.GetNamespace("mapi");
     Outlook.NameSpaceClass l_objOutlookNamespace = (Outlook.NameSpaceClass) 
l_objOutlookApp.GetNamespace("mapi");
     
     // Logon. If an outlook app is already open, then it will reuse that session.  
Else
     //   it will perform a fresh logon.  Note that if u have psts and passwords for 
the 
     // same, u need to enter the passwords in the dialogbox when they are shown
     l_objOutlookNamespace.Logon("SR", "", true, true);       // Get all the Contacts 
Folder
     cContacts = 
l_objOutlookNamespace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts);     
 //get all the COntacts from the Contacts Folder
     l_objContactItems = cContacts.Items;
     
     try
     {
      
for(l_intContactItemCtr=1;l_intContactItemCtr<=l_objContactItems.Count;l_intContactItemCtr++)
      {
       l_objContactItem = 
(Outlook.ContactItem)l_objContactItems.Item(l_intContactItemCtr);
       // Display some common properties.
       print("-------------------------------------------------------------");
       print("Information for Contact #" + l_intContactItemCtr + " of Total Contacts 
#" + l_objContactItems.Count);
       print("-------------------------------------------------------------");        
print("Full Name : " + l_objContactItem.FullName);
       print("Title  : " + l_objContactItem.Title);
       print("BirthDay : " + l_objContactItem.Birthday);
       print("CompanyName : " + l_objContactItem.CompanyName);
       print("Department  : " + l_objContactItem.Department);
       print("Body  : " + l_objContactItem.Body);
       print("FileAs  : " + l_objContactItem.FileAs);
       print("Email1Address  : " + l_objContactItem.Email1Address);
       print("BusinessHomePage  : " + l_objContactItem.BusinessHomePage);
       print("MailingAddress  : " + l_objContactItem.MailingAddress);
       print("BusinessAddress  : " + l_objContactItem.BusinessAddress);
        print("OfficeLocation  : " + l_objContactItem.OfficeLocation);
       print("Subject  : " + l_objContactItem.Subject);
       print("JobTitle  : " + l_objContactItem.JobTitle);
       print("-------------------------------------------------------------");
       Console.WriteLine("");
       // If you want the contact to be displayed, then uncomment the line below
       // After each item info is printed, the contact window will be shown and
       // only on closing that window, will the next contact be shown
       //l_objContactItem.Display(true);
      }
                     
     }
     catch(System.Exception  p_objException)
     {
      print("Error : " + p_objException.Message);
     }
     finally
     {       Console.Write("");
      Console.Write("Press Enter to quit application");
      Console.ReadLine   (); 
      Console.Write("");
      Console.Write("Logging off and Closing Outlook Application. This will take a 
moment.Pls wait...");       // Log off.
      l_objOutlookNamespace.Logoff();       // Clean up.
      l_objOutlookApp = null;
      l_objOutlookNamespace = null;
      l_objContactItems = null;
      l_objContactItem = null;      }
          }   hth   regards,   sr

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/BDotNet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you received 
this message by mistake, please click the "Remove" link below. On the pre-addressed 
e-mail message that opens, simply click "Send". Your e-mail address will be deleted 
from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to