none
C# with VS2012 read outlook 2010 body message and record

    Question

  • 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??
    Sunday, July 07, 2013 2:15 PM

Answers

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!

    Monday, July 08, 2013 6:01 AM
  • 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.

    Monday, July 08, 2013 6:18 AM
  • 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!

    Monday, July 08, 2013 6:22 AM
  • YES

    But the first thing is to read body message success

    Monday, July 08, 2013 7:25 AM
  • 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!

    Monday, July 08, 2013 7:29 AM
  • 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
    }

    Monday, July 08, 2013 7:33 AM
  • 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!

    Monday, July 08, 2013 7:40 AM
  • The problem are

    1.Application myApp = new ApplicationClass();

    2.folder = myApp.Session.Folders["inbox"];

    Monday, July 08, 2013 7:48 AM
  • 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

    Monday, July 08, 2013 10:17 AM
  • 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!


    Monday, July 08, 2013 1:20 PM
  • Sorry Sir.
    Monday, July 08, 2013 3:19 PM
  • Application myApp = new ApplicationClass();

    ^^^^^^^^^^^^^^^^^^^^^^^^^^

    here still have a problem

    Monday, July 08, 2013 3:22 PM
  • 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!

    Monday, July 08, 2013 3:38 PM
  • I am sorry, because my VS2012 is not english version.

    So I don't know to to explain this problem for you.

    Did you work with this code? what Visual Studio version do you used?

    Monday, July 08, 2013 3:47 PM
  • 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!

    Monday, July 08, 2013 4:37 PM
  • Still now working...

    Do you have some sample to read outlook 2010 mail message?

    Tuesday, July 09, 2013 12:18 AM
  • Do you think, if it is possible.

    I am use VS2012 + "Microsoft.Office.Interop.Outlook" 10.0 version.....to read outlook 2010.

    Microsoft.Office.Interop.Outlook should be 12.0 DLL   right??

    only 12.0 can read outlook 2010, maybe I guess.

    Tuesday, July 09, 2013 1:55 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!

    Tuesday, July 09, 2013 5:59 PM