Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > populating dataset with elements of outlook inbox

Thread Tools

populating dataset with elements of outlook inbox

Mike P
Posts: n/a
I have a collection of objects (oItems) that I want to use to populate a
dataset. Basically I want to take several elements from oItems (such as
SenderName, Subject and Body) and use them to populate separate columns
of a dataset, and then use the dataset to populate a gridview.
Can anybody help me out with this?

//Create Outlook application
Outlook.Application oApp = new Outlook.Application();

//Get MAPI namespace
Outlook.NameSpace oNS = oApp.GetNamespace("mapi");

oNS.Logon("name", "password", false, true);

//Get Messages collection of Inbox
Outlook.MAPIFolder oInbox =
oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFo lderInbox);

Outlook.Items oItems = oInbox.Items;

int intTotalNumberOfItemsInInbox = oItems.Count;

//Get unread e-mail messages
oItems = oItems.Restrict("[Unread] = true");
int intTotalUnread = oItems.Count;

//Loop through each unread message
Outlook.MailItem oMsg;
int i;

for (i = 1; i < oItems.Count; i++)
oMsg = (Outlook.MailItem)oItems.Item(i);

txtSenderName.Text = oMsg.SenderName.ToString();
txtSubject.Text = oMsg.Subject.ToString();
txtReceivedTime.Text = oMsg.ReceivedTime.ToString();
txtBody.Text = oMsg.Body.ToString();

//Log off

//Clean up
oApp = null;
oNS = null;
oItems = null;
oMsg = null;

*** Sent via Developersdex ***
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
populating webpage elements with contents of an iframe eureka Javascript 6 02-01-2007 12:23 PM
Populating a dataset from a stored proc in .NET 2.0 John ASP .Net 0 02-17-2006 05:49 PM
Populating form fields from a dataset =?Utf-8?B?TWljcm9Nb3Ro?= ASP .Net 1 03-07-2005 02:29 PM
Populating DataSet from two DataTables Ron ASP .Net Datagrid Control 1 07-18-2004 03:50 AM
Disabling auto-populating of form elements Jason Galvin ASP .Net 1 12-10-2003 06:49 AM