Outlook msg文件存储在本地磁盘,如何用delphi读取
我需要检索存储在本地磁盘上的 Outlook 消息文件的正文,并从每个文件中提取一些信息,它们的格式始终相同,只是数据发生变化,请告知。
提前致谢 Raul
谢谢大家,
由于限制自己回答,我将把我的解决方案写在我的问题下面。
我检查了一些 MS 文档,这是我的解决方案,按预期工作。
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;
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;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Raul,您可以自己检查
Outlook MSG 文件格式
或使用 Delphi 组件,例如SMMsg suite
。Raul, you can parse the msg files yourself checking the
Outlook MSG file format
or using a Delphi component likeSMMsg suite
.您可以尝试 Scalabium 的 SMMsg。
You could try SMMsg from Scalabium.