Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Outlook msg files stored in local disk, how to read with delphi

I need to retrieve the body of outlooks' msg files stored on a local disk and extract some information from each one, their format is always the same only the data changes, please advise.

thanks in advance Raul


Thanks to everybody,

due to the restriction to answer myself, I'll write my solution just below my question.

I've checked some MS documentation and here is my solution working as expected.

procedure TForm1.displayOutlookMsg(aFileName: string);
const
olFormatHTML = 2;
olFormatPlain = 1;
olFormatRichText = 3 ;
olFormatUnspecified = 0;

var outlook: OleVariant;
    outlookMsg, bodyMsg: variant;
begin

  try
    Outlook := GetActiveOleObject('Outlook.Application');
  except
    Outlook := CreateOleObject('Outlook.Application');
  end;

  outlookMsg:= outlook.CreateItemFromTemplate(aFileName);
  outlookMsg.bodyFormat := olFormatPlain;

  bodyMsg:= outlookMsg.body;

  Memo1.Lines.Add(VarToStr(bodyMsg));
  outlook:= unassigned;

end;
like image 526
Raul Avatar asked Jun 02 '11 14:06

Raul


People also ask

How do I read an Outlook message file?

Open the MSG with Outlook (in Windows): If you have access to Outlook, double-click the MSG and it'll automatically open using Outlook. If it doesn't, right-click on it, choose the 'Open With' option, and select 'Outlook'. Alternatively, you can copy/paste the MSG manually.

How do I read a .MSG file?

You can open an MSG file with Microsoft Outlook in Windows simply by double-clicking the file. If Outlook is not set as the default application for opening MSG files, you can right-click the file and choose Outlook to open the MSG file.

What programs can view MSG files?

Microsoft Outlook opens MSG files that are Outlook Mail Message files, but you don't have to have MS Outlook installed to view the file. Free Opener, MSG Viewer, MsgViewer Pro, and Email Open View Pro should work too. SeaMonkey should be able to view the MSG file on Windows, Linux, and macOS.

How do I view MSG files in Ubuntu?

Sign in to your Microsoft onedrive account and upload the . msg file. After upload, you can click on it to view the file contents.


1 Answers

Raul, you can parse the msg files yourself checking the Outlook MSG file format or using a Delphi component like SMMsg suite.

like image 161
RRUZ Avatar answered Sep 30 '22 01:09

RRUZ