从不在会话帐户中的非默认帐户发送邮件

编程入门 行业动态 更新时间:2024-10-11 19:21:21
本文介绍了从不在会话帐户中的非默认帐户发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我创建了以下...

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

更多推荐

从不在会话帐户中的非默认帐户发送邮件

本文发布于:2023-11-27 09:40:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1637550.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:帐户   发送邮件

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!