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.
p开发者_StackOverflowrocedure 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;
Raul, you can parse the msg files yourself checking the Outlook MSG file format
or using a Delphi component like SMMsg suite
.
You could try SMMsg from Scalabium.
精彩评论