locked
OutLook Emails

    Pregunta

  • Hi,
     
    I want to load all registered e-mails from outlook on a listview, it is possible?

    Thanks!
    miércoles, 17 de diciembre de 2008 17:43

Respuestas

  •  

    Hello,

    Welcome to Visual C# Express Forum.

    In your question, you mentioned registered e-mails?   Could you please tell us what registered e-mails actually means?   

    Supposed you want to load all the registration code e-mails of Visual Studio Express Editions, you can use Outlook COM interop to handle your issue.   The following codes could show e-mails from particular sender address in your Outlook Inbox folder.   Please remember to add Microsoft.Office.Interop.Outlook as reference in your Windows Form application project.

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

            Microsoft.Office.Interop.Outlook.Application oOutlook;

            Microsoft.Office.Interop.Outlook.NameSpace oNs;

            Microsoft.Office.Interop.Outlook.MAPIFolder oFldr;

     

            public Form1()

            {

                InitializeComponent();

                oOutlook = new Microsoft.Office.Interop.Outlook.Application();

                oNs = oOutlook.GetNamespace("MAPI");

     

                //getting mail folder from inbox

                oFldr = oNs.GetDefaultFolder(OlDefaultFolders.olFolderInbox);

                foreach (Microsoft.Office.Interop.Outlook.MailItem oMessage in oFldr.Items)

                {

                    if (oMessage.SenderEmailAddress.Equals("someone@microsoft.com"))

                        listView1.Items.Add("Sender: " +

                            oMessage.SenderName + " Subject: "

                            + oMessage.Subject);

                   

                }

            }

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

    In addition, you can find more reference on Outlook COM Interop information from the link below:
    http://msdn.microsoft.com/en-us/library/ms268893(VS.80).aspx

     

    Best Regards,
    Lingzhi


    Please remember to mark the replies as answers if they help and unmark them if they provide no help. http://forums.msdn.microsoft.com/en-US/csharpide/thread/8e9ed0d7-11ff-402a-8489-9b5f05eeb706 http://forums.msdn.microsoft.com/en-US/vssetup/thread/60424309-bd78-4ca2-b618-03c4a16123b6
    lunes, 22 de diciembre de 2008 8:16
    Moderador

Todas las respuestas

  •  

    Hello,

    Welcome to Visual C# Express Forum.

    In your question, you mentioned registered e-mails?   Could you please tell us what registered e-mails actually means?   

    Supposed you want to load all the registration code e-mails of Visual Studio Express Editions, you can use Outlook COM interop to handle your issue.   The following codes could show e-mails from particular sender address in your Outlook Inbox folder.   Please remember to add Microsoft.Office.Interop.Outlook as reference in your Windows Form application project.

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

            Microsoft.Office.Interop.Outlook.Application oOutlook;

            Microsoft.Office.Interop.Outlook.NameSpace oNs;

            Microsoft.Office.Interop.Outlook.MAPIFolder oFldr;

     

            public Form1()

            {

                InitializeComponent();

                oOutlook = new Microsoft.Office.Interop.Outlook.Application();

                oNs = oOutlook.GetNamespace("MAPI");

     

                //getting mail folder from inbox

                oFldr = oNs.GetDefaultFolder(OlDefaultFolders.olFolderInbox);

                foreach (Microsoft.Office.Interop.Outlook.MailItem oMessage in oFldr.Items)

                {

                    if (oMessage.SenderEmailAddress.Equals("someone@microsoft.com"))

                        listView1.Items.Add("Sender: " +

                            oMessage.SenderName + " Subject: "

                            + oMessage.Subject);

                   

                }

            }

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

    In addition, you can find more reference on Outlook COM Interop information from the link below:
    http://msdn.microsoft.com/en-us/library/ms268893(VS.80).aspx

     

    Best Regards,
    Lingzhi


    Please remember to mark the replies as answers if they help and unmark them if they provide no help. http://forums.msdn.microsoft.com/en-US/csharpide/thread/8e9ed0d7-11ff-402a-8489-9b5f05eeb706 http://forums.msdn.microsoft.com/en-US/vssetup/thread/60424309-bd78-4ca2-b618-03c4a16123b6
    lunes, 22 de diciembre de 2008 8:16
    Moderador
  • Hi Lingzhi Sun,

    Sorry, I´ve made a wrong question!

    I need the address list of my contacts... I need to put on a listview all my friends emails!

    It´s possible?

    Thanks a lot.
    martes, 23 de diciembre de 2008 12:46
  •  

    Hello,

    Yes, it is.

    You can refer to the following codes to get contacts information from Outlook into ListView.

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

        public partial class Form1 : Form

        {

            Microsoft.Office.Interop.Outlook.Application oOutlook;

            Microsoft.Office.Interop.Outlook.NameSpace oNs;

            Microsoft.Office.Interop.Outlook.MAPIFolder oFldr;

     

            public Form1()

            {

                InitializeComponent();

                oOutlook = new Microsoft.Office.Interop.Outlook.Application();

                oNs = oOutlook.GetNamespace("MAPI");

     

                //getting mail folder from Contacts

                oFldr = oNs.GetDefaultFolder(OlDefaultFolders.olFolderContacts);

                foreach (Microsoft.Office.Interop.Outlook.ContactItem contact in oFldr.Items)

                {

                    listView1.Items.Add(contact.FirstName + " " + contact.LastName + " " + contact.JobTitle + " " + contact.CompanyName);

                }

            }

        }

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

     

    Best Regards,
    Lingzhi


    Please remember to mark the replies as answers if they help and unmark them if they provide no help. http://forums.msdn.microsoft.com/en-US/csharpide/thread/8e9ed0d7-11ff-402a-8489-9b5f05eeb706 http://forums.msdn.microsoft.com/en-US/vssetup/thread/60424309-bd78-4ca2-b618-03c4a16123b6
    jueves, 25 de diciembre de 2008 9:11
    Moderador