问题描述
我创建了以下...
Outlook.MailItem oMail;
oMail = Inspector.CurrentItem;
Outlook.NameSpace session = oMail.Session;
Outlook.Accounts accounts = session.Accounts;
当循环访问帐户时,我会收到在Outlook中实际添加的帐户,但不是那些在帐户设置 - >更改 - >更多设置 - >高级中,通过打开这些添加邮箱添加
如何访问这些,并从中获取帐户信息,以便我可以在我的 oMail.SendUsingAccount = account
在Outlook 2007+中,以下代码将为您提供给定用户可以访问的委托Exchange邮箱(打开这些附加邮箱 EM>)。关键因素是会话数据和。
foreach(var store in Globals.ThisAddIn.Application.Session.Stores.Cast< Outlook.Store>()。其中(c => c.ExchangeStoreType == Outlook.OlExchangeStoreType.olExchangeMailbox))
Trace.WriteLine(store.DisplayName);
要代表另一个邮箱发送邮件,您应该使用属性 - 由于您在技术上只有一个帐户()。
I have created the following...
Outlook.MailItem oMail;
oMail = Inspector.CurrentItem;
Outlook.NameSpace session = oMail.Session;
Outlook.Accounts accounts = session.Accounts;
When looping through accounts, I get the accounts which has been added physically in Outlook, but not the ones added through the "Open these addition mailboxes" in Account Settings -> Change -> More Settings -> Advanced
How can I access those and get the account information from that so I can use it in my, oMail.SendUsingAccount = account
In Outlook 2007+, the code below will provide you with the delegate Exchange mailboxes a given user has access to (the "Open these additional mailboxes" listing). The key ingredient is the Session data Stores
and the ExchangeStoreType
.
foreach (var store in Globals.ThisAddIn.Application.Session.Stores.Cast<Outlook.Store>().Where(c=>c.ExchangeStoreType == Outlook.OlExchangeStoreType.olExchangeMailbox))
Trace.WriteLine(store.DisplayName);
To send a message on behalf of another mailbox, you should use the property MailItem.SendOnBehalfName
- since you technically only have one account (see this Outlook forums post).
这篇关于从不在会话帐户中的非默认帐户发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!