从不在会话帐户中的非默认帐户发送邮件 [英] Send mail from non default account which is not in the sessions accounts

查看:172
本文介绍了从不在会话帐户中的非默认帐户发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了以下...

  Outlook.MailItem oMail; 
oMail = Inspector.CurrentItem;
Outlook.NameSpace session = oMail.Session;
Outlook.Accounts accounts = session.Accounts;

当循环访问帐户时,我会收到在Outlook中实际添加的帐户,但不是那些在帐户设置 - >更改 - >更多设置 - >高级中,通过打开这些添加邮箱添加

如何访问这些,并从中获取帐户信息,以便我可以在我的 oMail.SendUsingAccount = account

解决方案

在Outlook 2007+中,以下代码将为您提供给定用户可以访问的委托Exchange邮箱(打开这些附加邮箱 EM>)。关键因素是会话数据 Stores ExchangeStoreType

  foreach(var store in Globals.ThisAddIn.Application.Session.Stores.Cast< Outlook.Store>()。其中​​(c => c.ExchangeStoreType == Outlook.OlExchangeStoreType.olExchangeMailbox))
Trace.WriteLine(store.DisplayName);

要代表另一个邮箱发送邮件,您应该使用属性 - 由于您在技术上只有一个帐户( 看到这个Outlook论坛的帖子 )。


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).

这篇关于从不在会话帐户中的非默认帐户发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆