[英]Exchange Routing Agent Detect Email Direction
We have an Exchange Trasport Agent, which is specifically a RoutingAgent. 我们有一个Exchange Trasport代理,它专门是一个RoutingAgent。 In the OnSubmittedMessage
event we need to inspect the MailItem
and determine if it is outbound or inbound. 在OnSubmittedMessage
事件中,我们需要检查MailItem
并确定它是出站还是入站。 I am currently looking at using the SmtpServer.AcceptedDomains
property to check if the sender email is in the accepted domains list. 我目前正在使用SmtpServer.AcceptedDomains
属性检查发件人电子邮件是否在“接受的域”列表中。 Here is an example of how we are trying to do this: 这是我们尝试执行此操作的示例:
private bool IsOutbound(MailItem mailItem, AcceptedDomainCollection acceptedDomains)
{
if (acceptedDomains.Find(mailItem.FromAddress) != null)
{
return true;
}
return false;
}
I am not extremely familiar with Accepted Domains, and I am trying to understand if this is a viable solution to reliably determine the direction of an email? 我对“接受域”不是很熟悉,我试图了解这是否是可靠确定电子邮件方向的可行解决方案? This scenario also needs to work for companies that have multiple domains included in their Exchange organization setup. 此方案还需要适用于Exchange组织设置中包含多个域的公司。 Note that we plan to support Exchange 2010-2016 if that makes any difference. 请注意,如果有任何不同,我们计划支持Exchange 2010-2016。
--EDIT-- - 编辑 -
After getting some help from @GlenScales I realize I need to update my question a bit. 从@GlenScales获得一些帮助后,我意识到我需要稍微更新一下我的问题。
My goal is to determine if the sender of the email is in a domain that is internal to the Exchange organization. 我的目标是确定电子邮件的发件人是否在Exchange组织内部的域中。 This could also be achieved by determining if the email was generated within Exchange, we are able to inspect the recipients at a later stage just fine and see if it is inbound or outbound. 这也可以通过确定电子邮件是否是在Exchange中生成的来实现的,我们可以在以后的阶段很好地检查收件人并查看它是入站还是出站。
With that being said, we looked at 3 possible solutions: 话虽如此,我们研究了3种可能的解决方案:
In the end we decided that we really wanted to be inspecting messages that were generated from a mailbox only and went with #3. 最后,我们决定我们真的想检查仅从邮箱生成并与#3一起发送的邮件。 #1 sounded like it could potentially include domains that were really just "forwarding" domains, and we do not want to consider those messages in our application. #1听起来似乎可能包含实际上只是“转发”域的域,并且我们不想在应用程序中考虑这些消息。
AcceptedDomains tells you all the SMTP domains that the Exchange Organization will delver for. AcceptedDomains会告诉您Exchange组织将要研究的所有SMTP域。 Eg When the Exchange Transport Server performs message categorization on a Message if the Message is To an Address that is within the Accepted domains it will take responsibility for delivery that message to that recipients (there can be multiple recipients in a message so that point the message maybe forked and delivered to the Internal recipient and the sent on to the external recipient). 例如,如果Exchange传输服务器对邮件进行邮件分类(如果邮件是到接受域内的地址),它将负责将该邮件传递给该收件人(邮件中可以有多个收件人,以便指向该邮件也许分叉并传递给内部收件人,然后发送给外部收件人)。
What your doing just tells you where the Sender is from not really the direction of the Message as such. 您所做的只是告诉您发件人在哪里,而实际上并不是消息的方向。 OnSubmittedMessage means you capturing a Message before any categorization has taken place in the case it's a message that has been sent from within your org but if the message has both internal and external recipients some copies the it will have multiple destinations. OnSubmittedMessage意味着您是在组织内部发送邮件的情况下,在进行任何分类之前捕获邮件的,但是如果该邮件同时具有内部和外部收件人,则该邮件将具有多个目的地。
There also some other options in https://social.msdn.microsoft.com/Forums/en-US/9387e62a-76d7-4340-b9cc-f87ffcfab8b1/how-to-detect-the-message-source-in-an-exchange-server-2013-transport-agent-for-getting-the-sending?forum=exchangesvrdevelopment which I'd suggest you look at https://social.msdn.microsoft.com/Forums/zh-CN/9387e62a-76d7-4340-b9cc-f87ffcfab8b1/how-to-detect-the-message-source-in-an- exchange-server-2013-transport-agent-for-the-send-send?forum = exchangesvrdevelopment ,我建议您看一下
Cheers Glen 干杯格伦
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.