This article will show you how you can read all the email
present in your outlook and get the total count using c#.net.
Some of my previous articles are as follows: Code
to Convert or Writing DataSet Contents Into An XML Data File Using C#.Net In
Asp.Net, How
To Read XML File In DataSet And Display in DataGridview Using C#.Net, WebBrowser
Control in C#, Windows Application, Change
Control Font Size At Runtime / Dynamically Using C#.Net and VB.Net In Windows
Application, Export
GridView Data To Excel Sheet Using C#.Net In Windows Application, Windows
Application In C#.Net (My first video article on youtube.com), How
to Create a Code 128 Barcode Label Using windows Font in C# ,Windows
Application, How
To Get Enumerate Installed Fonts List In Your Computer Using C# Windows
Application.
Now have a look of the outlook email count.
So for this demo we will create a new windows application
and add some button and label control in form. Now we will add the outlook
library reference.
Now on button click add the below code.
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Outlook = Microsoft.Office.Interop.Outlook;
namespace WindowsFormsApplication5
{
public partial class Form1 : Form
{
public
Form1()
{
InitializeComponent();
}
private
void button1_Click(object
sender, EventArgs e)
{
List<string> objSubjectList = new List<string>();
Outlook.Application
objApplication = new Outlook.Application();
Outlook.MAPIFolder
objInboxEmail =
objApplication.ActiveExplorer().Session.GetDefaultFolder(Outlook.OlDefaultFolders.
olFolderInbox);
label2.Text =
objInboxEmail.Items.Count.ToString();
}
}
}
|
In above code I have read all the email from outlook and display the count. Now we have done run the application to check the output. Have a look of the application in debug mode.
Now press F5 to check the final output.
DOWNLOAD
0 comments:
Please let me know your view