473,626 Members | 3,322 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

reading email from outlook

12 New Member
Hi there
im writing a program that has to read email from outlook. does anyone know how?
I managed to read all the subjects in my inbox but i'd like to read the 1st 1 in the inbox. here's the code i used to read the subjects..

Outlook.Applica tion app = new Outlook.Applica tionClass();
Outlook.NameSpa ce NS = app.GetNamespac e("MAPI");
Outlook.MAPIFol der inboxFld = NS.GetDefaultFo lder(Outlook.Ol DefaultFolders. olFolderInbox);

foreach(Outlook .MailItem t in inboxFld.Items)
{
Console.WriteLi ne(t.Subject);
}
thanks,
lil hamster
Dec 5 '07 #1
3 1682
radcaesar
759 Recognized Expert Contributor
objFolder =oNameSpace.Get DefaultFolder(O utlook.OlDefaul tFolders.olFold erInbox );
Outlook.Items oItems;
oItems = objFolder.Items ;

for (int i=0; i<objFolder.Ite ms.Count;i++)
{
objMail = (Outlook.MailIt em)objFolder.It ems.GetNext();
System.Diagnost ics.Debug.Write Line(objMail.Bo dy.ToString());
}

Restrict the count based on ur requirement in the above code.
Dec 5 '07 #2
hamster
12 New Member
Hi i tried that code but im not getting any output this is mot i used now:

Outlook.Applica tion app = new Outlook.Applica tionClass();
Outlook.NameSpa ce oNameSpace = app.GetNamespac e("MAPI");
Outlook.MAPIFol der objFolder = oNameSpace.GetD efaultFolder(Ou tlook.OlDefault Folders.olFolde rInbox);
Outlook._MailIt em objMail;

objFolder =oNameSpace.Get DefaultFolder(O utlook.OlDefaul tFolders.olFold erInbox);
Outlook.Items oItems;
oItems = objFolder.Items ;

for (int i=0; i<objFolder.Ite ms.Count;i++)
{
objMail = (Outlook.MailIt em)objFolder.It ems.GetNext();
System.Diagnost ics.Debug.Write Line(objMail.Bo dy.ToString());
}
Dec 6 '07 #3
hamster
12 New Member
hi does anyone have any ideas?
thanx
Dec 11 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
6088
by: PIII450 | last post by:
Hi all, Does anyone know of a class which will read outlook email messages. I need to be able to scan outlook for "non-read" e-mails with a specific subject and then save the attachments and mark the e-mail as "read". I tried working with the am outlook application COM object but could not get it to work. If you have another way to do what I want, without human intervention, I'm open for suggestions. I't goes without saying I want to...
4
14685
by: Greg Smith | last post by:
I have an old application that analyzes the data in the event log on one of our servers. I would like to convert it to C#. Does anybody know of any examples of reading the event log on a remote system in C#. Any help is greatly appreciated.
0
2143
by: VP | last post by:
g'day, i am posting a problem i have encountered with creating an email using outlook through some basic c# code. the problem arises when using different email editors in outlook. At the moment i am using outlook 2000. Outlook can be configured to use the default outlook email editor or use ms word as the email editor in outlook. The sample code below simply creates an email with a hyperlink. The problem I am facing is that when...
1
1325
by: bobdydd | last post by:
Hi Guys I arrived at the holy grail of Access 2000 programming about a year ago, when I found out how to READ AND WRITE to and from the Microsoft Outlook Inbox <smug> Now the pesky endusers are saying they want to be able to use the program when the default email client is something other than Microsoft Outlook. Like Outlook Express or Eudora.
4
2260
by: JJ | last post by:
Whats the most compatilbe way of sending an email ?- I need to consider that the OS may be win 98/win NT/Win 2000/winXP. I was constructing a mailto command, but the contents of the text file I am using as the subject is too long and gets cut off. I therefore need a method that doesn't use the limitations of mailto (in terms of the length of the subject text) or allows me to add the text file as an attachment. I am using VB 2003. I...
4
2019
by: ethan220 | last post by:
Is it possible to read Outlook mails in PHP?? I would like to create a php program that reads mails from a particular person which are downloaded in MS Outlook. Ethan
0
1417
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
0
1192
by: AMP | last post by:
On running the followig code, with a time that fires every 30 seconds Dim oApp As Outlook.Application = New Outlook.Application ' String used for comparison with mail item. ' Get Mapi NameSpace. Dim oNS As Outlook.NameSpace = oApp.GetNamespace("MAPI") oNS.Logon("USER", "password", False, True) ' Get Messages collection of Inbox. Dim oInbox As Outlook.MAPIFolder = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
4
2830
by: venutaurus539 | last post by:
Hello, I was getting an error in Cocreate instance while trying to access "Outlook" using python script. The python script looks like: from win32com.client import Dispatch session = Dispatch("MAPI.session") session.Logon('OUTLOOK') # MAPI profile name inbox = session.Inbox When I tried to execute the script I got the error:
0
8196
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
8705
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8637
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...
0
8504
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6125
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5574
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
4197
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1808
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1511
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.