connectseekers.com

Saturday, 22 August 2015

Read Outlook Email Subject Using c#

8/22/2015 - By Pranav Singh 0

This article will show you how you can read the email from outlook and get the email subject line using c#. In this article I have shown how to get outlook email and display the subject line into listbox using c#.net.


CODE
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Outlook = Microsoft.Office.Interop.Outlook;
using System.Data;
namespace WindowsFormsApplication5
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            List<string> objSubjectList = new List<string>();
            DataTable objDt = new DataTable();
            Outlook.Application objApplication = new Outlook.Application();
            Outlook.MAPIFolder objInboxEmail = objApplication.ActiveExplorer().Session.GetDefaultFolder(
Outlook.OlDefaultFolders.olFolderInbox);
            for (int i = 1; i <= objInboxEmail.Items.Count; i++)
            {
                objSubjectList.Add(((Outlook.MailItem)objInboxEmail.Items[i]).Subject);
            }
            listBox1.DataSource = objSubjectList;
        }
    }
}

In above code I have read the outlook email and created the subject line collection to bind it to the listbox control.
Now we have done run the application to check the output.


About the Author

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post

0 comments:

Please let me know your view

Free Ebooks


About Us

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Contact Us

For writing article in this website please send request by your

GMAIL ID: dotnetpools@gmail.com
Email Id : contact@aspdotnet-pools.com

Bugs and Suggestions

As we all know that this website is for sharing knowledge and providing proper solution. So while reading the article is you find any bug or if you have any suggestion please mail us at contact@aspdotnet-pools.com.

Partners


Top jQuery Plugins

Global Classified : Connectseekers.com
© 2014
back to top