"can i read an outlook (2003/2007) pst file in c#?" Code Answer


the outlook interop library is not just for addins. for example it could be used to write a console app that just reads all your outlook contacts. i am pretty sure that the standard microsoft outlook interop library will let you read the mail - albeit it will probably throw a security prompt in outlook that the user will have to click through.

edits: actually implementing mail reading using outlook interop depends on what your definition of 'standalone' means. the outlook interop lib requires outlook to be installed on the client machine in order to function.

// dumps all email in outlook to console window.
// prompts user with warning that an application is attempting to read outlook data.
using system;
using system.collections.generic;
using system.linq;
using system.text;
using outlook = microsoft.office.interop.outlook;

namespace outlookemail
class program
    static void main(string[] args)
        outlook.application app = new outlook.application();
        outlook.namespace outlookns = app.getnamespace("mapi");
        outlook.mapifolder emailfolder = outlookns.getdefaultfolder(microsoft.office.interop.outlook.oldefaultfolders.olfolderinbox);

        foreach (outlook.mailitem item in emailfolder.items)
            console.writeline(item.senderemailaddress + " " + item.subject + "n" + item.body);
By Sherbrow on May 30 2022

Answers related to “can i read an outlook (2003/2007) pst file in c#?”

Only authorized users can answer the Search term. Please sign in first, or register a free account.