使用OLE检索Delphi中的Outlook“收件箱"和“已发送"文件夹 [英] Retrieving Outlook 'Inbox' and 'Sent' folders in Delphi using OLE
本文介绍了使用OLE检索Delphi中的Outlook“收件箱"和“已发送"文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从Delphi中提取Outlook文件夹的最佳方法是什么?理想情况下,我想检索收件箱"文件夹和其中的任何其他文件夹.我只需要文件夹名称就不需要电子邮件标题/消息.
What's the best way to go about extracting Outlook folders from within Delphi? 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
Delphi BDS 2006
推荐答案
See here for Outlook's Object Model. 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;
这篇关于使用OLE检索Delphi中的Outlook“收件箱"和“已发送"文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文