473,812 Members | 2,852 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Applica tion oApp = new Outlook.Applica tion();

//Get MAPI namespace
Outlook.NameSpa ce oNS = oApp.GetNamespa ce("mapi");

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

//Get Messages collection of Inbox
Outlook.MAPIFol der oInbox =
oNS.GetDefaultF older(Outlook.O lDefaultFolders .olFolderInbox) ;

Outlook.Items oItems = oInbox.Items;

int intTotalNumberO fItemsInInbox = oItems.Count;

//Get unread e-mail messages
oItems = oItems.Restrict ("[Unread] = true");
int intTotalUnread = oItems.Count;
//Loop through each unread message
Outlook.MailIte m oMsg;
int i;

for (i = 1; i < oItems.Count; i++)
{
oMsg = (Outlook.MailIt em)oItems.Item( i);

txtSenderName.T ext = oMsg.SenderName .ToString();
txtSubject.Text = oMsg.Subject.To String();
txtReceivedTime .Text = oMsg.ReceivedTi me.ToString();
txtBody.Text = oMsg.Body.ToStr ing();
}

//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 1058

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

Similar topics

2
4746
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 this type of task? I mean to say is it possible to append some text in outlook inbox messages.If yes, could you please provide a script which does this task. The application which i'm intended to develop is windows service application. And at the...
1
8232
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 Access to import l;oop though my inbox and pick up all the usesr defined field data from any messages froma specific subject. I have have mixed and matched some code I found on the net however it doesn't seem to work properly. problems I face are:
3
1488
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
6047
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 "LabLocation_ID". With an existing lab, they then need to add the members for that lab. So, what I am trying to do is the following. With the FormView of the Lab open, the user will click a button to open a FormView (InsertMode) and add a new...
7
6813
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 Inbox As Outlook.MAPIFolder Dim InboxItems As Outlook.Items Dim Mailobject As Object Set OlApp = CreateObject("Outlook.Application")
0
1411
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 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();
0
1424
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 email address. Can anyone help? Fred Zuckerman Private Sub btnScanInbox_Click() Dim rst As DAO.Recordset Dim OlApp As Outlook.Application
2
4601
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 MAPI.Session Dim objInbox As MAPI.Folder Dim objMessages As MAPI.Messages Dim objMessage As MAPI.Message
0
1271
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 showing how to do that, but they all assume that the Outlook inbox contains MailItems only. This is definitely not true, I have identified - so far - some 18 item types which might also be found in the Outlook inbox.
0
9734
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9607
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10404
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10417
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9219
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6897
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5568
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5704
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3881
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.