Answered by:
C# with VS2012 read outlook 2010 body message and record

-
Dear Sir.,
I am use C# vs2012 to read outlook 2010's pst message
which message as below
======================================
Mobile Position Report
Pacific Region, ID : 18449, Number : 195
Position : 2 09.72' N, 176 14.08' E
Speed : 0.0 knots, head : 93 degree
======================================
How can I read this field value and make it become one row's csv file and record??- Moved by Cindy Meister MVPMVP Monday, July 08, 2013 8:29 AM Outlook-specific
Question
Answers
-
That is not a valid C# code - you need to have a namespace, then the class, then the actual class variable declarations.
Dmitry Streblechenko (MVP) http://www.dimastr.com/redemption
Redemption - what the Outlook
Object Model should have been
Version 5.5 is now available!- Marked as answer by Quist ZhangModerator Thursday, July 18, 2013 11:44 AM
-
What is the exact error?
Try to change that line to
Application myApp = new Application();
Dmitry Streblechenko (MVP) http://www.dimastr.com/redemption
Redemption - what the Outlook
Object Model should have been
Version 5.5 is now available!- Marked as answer by Quist ZhangModerator Thursday, July 18, 2013 11:44 AM
-
So it cannot recognize the "Application" type? Change that line to
Microsoft.Office.Interop.Outlook.Application myApp = new Microsoft.Office.Interop.Outlook.Application();
Dmitry Streblechenko (MVP) http://www.dimastr.com/redemption
Redemption - what the Outlook
Object Model should have been
Version 5.5 is now available!- Marked as answer by Quist ZhangModerator Thursday, July 18, 2013 11:44 AM
All replies
-
Didn't the suggestions above work for you?
What have you tried and what exactly does not work?
Dmitry Streblechenko (MVP) http://www.dimastr.com/redemption
Redemption - what the Outlook
Object Model should have been
Version 5.5 is now available! -
Hi Dimtry
I am use C# vs2012 to read outlook 2010's pst message
which message as below======================================Mobile Position Report
Pacific Region, ID : 18449, Number : 195
nbsp; 2 09.72' N, 176 14.08' E
Speed : 0.0 knots, head : 93 degree======================================How can I read this field value and make it become one row's csv file and record??
For now, I still don't success to read any message yet after I search so many topic.
-
I am not sure what is has to do with the original question.
You would need to read the MailItem.Body property and parse it into multiple values.
Dmitry Streblechenko (MVP) http://www.dimastr.com/redemption
Redemption - what the Outlook
Object Model should have been
Version 5.5 is now available! -
-
Have you tried MailItem.Body? You need to be a lot more specific than that: what exactly have you tried?
Dmitry Streblechenko (MVP) http://www.dimastr.com/redemption
Redemption - what the Outlook
Object Model should have been
Version 5.5 is now available! -
Not success
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Office.Interop.Outlook
Application myApp = new ApplicationClass();
NameSpace mapiNameSpace = myApp.GetNamespace("MAPI");
MAPIFolder folder;
folder = myApp.Session.Folders["inbox"];
folder = mapiNameSpace.GetDefaultFolder(OlDefaultFolders.olFolderInbox);
foreach (MailItem mail in folder.Items) {
string subject = mail.Subject;
string body = mail.Body; // this will trigger the security warning...
string senderName = mail.SenderName;
string senderEmail = mail.SenderEmailAddress; // security warning
} -
So the problem is the security prompt? See http://www.outlookcode.com/article.aspx?id=52 for your options.
Dmitry Streblechenko (MVP) http://www.dimastr.com/redemption
Redemption - what the Outlook
Object Model should have been
Version 5.5 is now available! -
-
Dmitri, Tsai Fon Jim:
Tsai Fon Jim posted this same question as an independent message that should now be visible in the Outlook for Developers forum. I'm going to split this discussion off the Answered question and TRY to merge it to that question.
@Tsai Fon Jim: PLEASE do not post unrelated questions to an older discussion that has been marked as "Answered". In forum jargon, this is called "piggy-backing" and is considered to be incorrect forum etiquette.
Cindy Meister, VSTO/Word MVP, my blog
-
If you need to open the Inbox folder, use Namespace.GetDefaultFolder(olFolderInbox).
As Cindy already mentioned, create a new thread instead of hijacking an old one and please be as specific as possible when describing your problem.
Dmitry Streblechenko (MVP) http://www.dimastr.com/redemption
Redemption - what the Outlook
Object Model should have been
Version 5.5 is now available!- Edited by Dmitry Streblechenko _MVP_MVP Monday, July 08, 2013 1:20 PM grammar
-
-
-
What is the exact error?
Try to change that line to
Application myApp = new Application();
Dmitry Streblechenko (MVP) http://www.dimastr.com/redemption
Redemption - what the Outlook
Object Model should have been
Version 5.5 is now available!- Marked as answer by Quist ZhangModerator Thursday, July 18, 2013 11:44 AM
-
-
So it cannot recognize the "Application" type? Change that line to
Microsoft.Office.Interop.Outlook.Application myApp = new Microsoft.Office.Interop.Outlook.Application();
Dmitry Streblechenko (MVP) http://www.dimastr.com/redemption
Redemption - what the Outlook
Object Model should have been
Version 5.5 is now available!- Marked as answer by Quist ZhangModerator Thursday, July 18, 2013 11:44 AM
-
-
-
That is not a valid C# code - you need to have a namespace, then the class, then the actual class variable declarations.
Dmitry Streblechenko (MVP) http://www.dimastr.com/redemption
Redemption - what the Outlook
Object Model should have been
Version 5.5 is now available!- Marked as answer by Quist ZhangModerator Thursday, July 18, 2013 11:44 AM