[英]Retrieving Outlook 'Inbox' and 'Sent' folders in Delphi using OLE
What's the best way to go about extracting Outlook folders from within Delphi? 从Delphi中提取Outlook文件夹的最佳方法是什么? Ideally I'd like to retrieve the Inbox folder and any other folders within it. 理想情况下,我想检索收件箱文件夹及其中的任何其他文件夹。 I don't require the email headers/message just purely the folder names. 我不要求电子邮件标题/消息纯粹是文件夹名称。
Delphi BDS 2006 德尔福BDS 2006
See here for Outlook's Object Model. 请参阅此处了解Outlook的对象模型。 Below displays the names of folders in the Inbox: 下面显示收件箱中文件夹的名称:
procedure TForm1.Button1Click(Sender: TObject);
var
Outlook, oNameSpace, Inbox: OleVariant;
i: Integer;
begin
try
Outlook := GetActiveOleObject('Outlook.Application');
except
Outlook := CreateOleObject('Outlook.Application');
end;
oNameSpace := Outlook.GetNamespace('MAPI');
oNameSpace.Logon('', '', False, False); // not sure if this is necessary
Inbox := oNameSpace.GetDefaultFolder(olFolderInbox);
for i := 1 to Inbox.Folders.Count do
ShowMessage(Inbox.Folders[i].Name);
end;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.