Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Put outlook folder items into a grid

Status
Not open for further replies.

spangeman

Programmer
Oct 16, 2004
96
EU
Hi

Using an example I have written some code to put the contents of my outlook inbox into a string. How can I put the results into a grid on my form?

I'd like to be able to select which fields go onto the form.

Cheers
Spange

namespace OutlookExamples
{
public partial class Form1 : Form
{

private Outlook.Application oApp;
public Outlook._MailItem[] oMailItems;


public Form1()
{
InitializeComponent();
oApp = new Outlook.Application();
}

private void Form1_Load(object sender, EventArgs e)
{
string strOutput = "";
Outlook.MAPIFolder fldInbox = (Outlook.MAPIFolder)oApp.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
fldInbox.Items.Sort("[SentOn]", false);

foreach (Outlook._MailItem oMailItem in fldInbox.Items.Restrict("[SentOn] >= '01/01/2009'"))
{
strOutput = strOutput + oMailItem.Subject + " - " + oMailItem.SentOn + Environment.NewLine;
}

MessageBox.Show(strOutput);
}

}
}
 
You can build an object collection and then bind it to the grid.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top