reading email from outlook

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hamster
    New Member
    • Mar 2007
    • 12

    reading email from outlook

    Hi there
    im writing a program that has to read email from outlook. does anyone know how?
    I managed to read all the subjects in my inbox but i'd like to read the 1st 1 in the inbox. here's the code i used to read the subjects..

    Outlook.Applica tion app = new Outlook.Applica tionClass();
    Outlook.NameSpa ce NS = app.GetNamespac e("MAPI");
    Outlook.MAPIFol der inboxFld = NS.GetDefaultFo lder(Outlook.Ol DefaultFolders. olFolderInbox);

    foreach(Outlook .MailItem t in inboxFld.Items)
    {
    Console.WriteLi ne(t.Subject);
    }
    thanks,
    lil hamster
  • radcaesar
    Recognized Expert Contributor
    • Sep 2006
    • 759

    #2
    objFolder =oNameSpace.Get DefaultFolder(O utlook.OlDefaul tFolders.olFold erInbox );
    Outlook.Items oItems;
    oItems = objFolder.Items ;

    for (int i=0; i<objFolder.Ite ms.Count;i++)
    {
    objMail = (Outlook.MailIt em)objFolder.It ems.GetNext();
    System.Diagnost ics.Debug.Write Line(objMail.Bo dy.ToString());
    }

    Restrict the count based on ur requirement in the above code.

    Comment

    • hamster
      New Member
      • Mar 2007
      • 12

      #3
      Hi i tried that code but im not getting any output this is mot i used now:

      Outlook.Applica tion app = new Outlook.Applica tionClass();
      Outlook.NameSpa ce oNameSpace = app.GetNamespac e("MAPI");
      Outlook.MAPIFol der objFolder = oNameSpace.GetD efaultFolder(Ou tlook.OlDefault Folders.olFolde rInbox);
      Outlook._MailIt em objMail;

      objFolder =oNameSpace.Get DefaultFolder(O utlook.OlDefaul tFolders.olFold erInbox);
      Outlook.Items oItems;
      oItems = objFolder.Items ;

      for (int i=0; i<objFolder.Ite ms.Count;i++)
      {
      objMail = (Outlook.MailIt em)objFolder.It ems.GetNext();
      System.Diagnost ics.Debug.Write Line(objMail.Bo dy.ToString());
      }

      Comment

      • hamster
        New Member
        • Mar 2007
        • 12

        #4
        hi does anyone have any ideas?
        thanx

        Comment

        Working...