我在 SharedMailbox 中尝试选择子文件夹时遇到问题。
我已在GetSharedDefaultFolder
上阅读了一些资源。
然而,正在努力将它正确地组合在一起
如果你可以帮忙解决这个问题真的很棒。
Sub ListOutlookEmailInfoInExcel()
Dim olNS As Outlook.NameSpace
Dim olTaskfolder As Outlook.MAPIFolder
Dim olTask As Outlook.TaskItem
Dim olItems As Outlook.Items
Set o1NS = GetNamespace("MAPI")
Set o1TaskFolder = o1NS.GetSharedDefaultFolder("Shared Folder 1", _
olFolderInbox).Folders("admin")
Set o1Items = o1TaskFolder.Items
End Sub
答案 0 :(得分:0)
您首先按照此处http://www.slipstick.com/developer/working-vba-nondefault-outlook-folders/
所述解析所有者"您可以在解析收件人时使用邮箱所有者的显示名称,别名或电子邮件地址。"
Sub ListOutlookEmailInfoInExcel()
Dim olNS As Outlook.NameSpace
Dim olTaskfolder As Outlook.MAPIFolder
Dim olTask As Outlook.TaskItem
Dim olItems As Outlook.Items
Dim objOwner As Outlook.Recipient
Set olNS = GetNamespace("MAPI")
Set objOwner = olNS.CreateRecipient("Shared Folder 1")
objOwner.Resolve
If objOwner.Resolved Then
Set olTaskFolder = olNS.GetSharedDefaultFolder(objOwner, _
olFolderInbox).Folders("admin")
Set olItems = olTaskFolder.Items
End If
End Sub
答案 1 :(得分:-1)
Namespace类的GetSharedDefaultFolder方法接受两个参数:Recipient对象和FolderType值。
How to: Display a Shared Calendar of a Recipient文章在C#中提供了以下示例代码:
private void DisplayManagerCalendar()
{
Outlook.AddressEntry addrEntry =
Application.Session.CurrentUser.AddressEntry;
if (addrEntry.Type == "EX")
{
Outlook.ExchangeUser manager =
Application.Session.CurrentUser.
AddressEntry.GetExchangeUser().GetExchangeUserManager();
if (manager != null)
{
Outlook.Recipient recip =
Application.Session.CreateRecipient(manager.Name);
if (recip.Resolve())
{
try
{
Outlook.Folder folder =
Application.Session.GetSharedDefaultFolder(
recip, Outlook.OlDefaultFolders.olFolderCalendar)
as Outlook.Folder;
folder.Display();
}
catch
{
MessageBox.Show("Could not open manager's calendar.",
"GetSharedDefaultFolder Example",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
}
}