从 Outlook 中的约会项目获取 Internet 日历的所有者电子邮件地址



我正在开发一个Outlook加载项,其中我正在尝试在日历项添加事件中获取日历的Onwer电子邮件ID。我在下面的帖子中尝试了该方法,它适用于默认帐户,但是当日历是互联网日历订阅时,它不起作用。

获取约会项目的日历所有者电子邮件地址

AppointmentItem.ParentStoreID 与任何Account对象都不匹配,如果是 Internet 日历。还有其他方法可以获取日历所有者电子邮件地址吗?

感谢您的帮助!

我正在使用以下代码

GetCalendarOwner(Outlook.AppointmentItem appointment)
{
Outlook.MAPIFolder folder = appointment.Parent;
string email = "";
foreach (Outlook.Account account in Application.Session.Accounts)
{
Outlook.MAPIFolder folder2 = account.DeliveryStore.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);
if (Application.Session.CompareEntryIDs(folder.Store.StoreID, account.DeliveryStore.StoreID))
{
Outlook.AddressEntry accountEmail = account.CurrentUser.AddressEntry;
if (accountEmail != null)
{
if (accountEmail.AddressEntryUserType ==
Outlook.OlAddressEntryUserType.olExchangeUserAddressEntry ||
accountEmail.AddressEntryUserType ==
Outlook.OlAddressEntryUserType.olExchangeRemoteUserAddressEntry)
{
Outlook.ExchangeUser exchUser = accountEmail.GetExchangeUser();
if (exchUser != null)
{
email = exchUser.PrimarySmtpAddress;
}
}
else
{
email = account.SmtpAddress;
if (string.IsNullOrEmpty(email))
{
email = accountEmail.Address;
}
}
}
break;
}
}
return email;
}

不清楚ItemSend事件处理程序中到底使用了什么代码。无论如何,您似乎对 MeetingItem.SendUsingAccount 属性感兴趣,该属性返回或设置一个Account对象,该对象表示用于发送MeetingItem的帐户。

可以使用 SendUsingAccount 属性来指定 Send 方法用于发送会议项的帐户。如果为会议项指定的帐户不再存在或使用默认/主帐户,则此属性返回 Null(Visual Basic 中没有任何内容((请参见Namespace.CurrentUser(。

最新更新