473,387 Members | 1,844 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

populating dataset with elements of outlook inbox

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
oNS.Logoff();

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

*** Sent via Developersdex http://www.developersdex.com ***
Feb 19 '07 #1
0 1042

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: sudheer | last post by:
Hi, Thank you in advance. I need to devlop an application, which reads the outlook inbox messages and appends some additional message to the read messages. I want to know is it possible to do...
1
by: KS | last post by:
Hi, I have creatd a custom Outlook form with a few custom form fields. When completed the form is sent to me and goes into my Inbox. This works fine. Now Iam trying to write some code in...
3
by: Lars Netzel | last post by:
I need to know if I can look for "Inbox" or as in Swedish "Inkorgen"... or can one asume I that the Inbox has a special index if I loop thru the folders? /Lars Netzel
3
by: sck10 | last post by:
Hello, I am creating a form for users to enter information about a lab and the members of the lab. I have one form (FormView) that they use to enter information about that lab. The keyvalue is...
7
by: Dean Spencer | last post by:
Can anyone help? I am importing Emails from Outlook using the following code: Public Function ScanInbox(SubjectLine As String) Dim TempRst As Recordset Dim OlApp As Outlook.Application Dim...
0
by: Mike P | last post by:
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...
0
by: Fred Zuckerman | last post by:
Hello All, I'm trying to read my Outlook Inbox and add email addresses to an Access table. My code is below. It works fine except there doesn't seem to be a mailobject property for the senders...
2
by: bill | last post by:
I have this code to get to the default Outlook inbox but I would like to get to the inbox of an additional added mailbox. Can this be done? Here is the code I'm using below: Dim objSession As...
0
by: =?Utf-8?B?UGF1bEg=?= | last post by:
Hi, I am writing an application which (on user request) scans the Outlook inbox for messages and other items which are relevant in the user defined context. There are several code examples...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.