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;
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.
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.
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.
Sign in to your Microsoft onedrive account and upload the . msg file. After upload, you can click on it to view the file contents.
Raul, you can parse the msg files yourself checking the Outlook MSG file format
or using a Delphi component like SMMsg suite
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With