简体   繁体   English

Exchange 2007 NDR到公用文件夹

[英]Exchange 2007 NDRs to public Folders

Exchange deletes Non-Delivery-Reports (NDRs) if the target is a public folder. 如果目标是公用文件夹,则Exchange删除未送达报告(NDR)。

I want to write a Transport Agent (SMTPReceiveAgent, c#) to bypass this behavior. 我想编写一个传输代理(SMTPReceiveAgent,c#)来绕过此行为。 The goal is to change the NDR to a "normal" mail, that dont delete by exchange. 目的是将NDR更改为“普通”邮件,不要通过交换删除。 I test some thinks around this and found no solution. 我测试了一些对此的想法,但没有找到解决方案。 Now i need help. 现在我需要帮助。

Here some questions: 这里有一些问题:

  1. It's easy to identify an NDR. 识别NDR很容易。

    Content-Type: multipart/report; 内容类型:多部分/报告; report-type=delivery-status; report-type =交付状态;

    But what i have to change at the mail to convert this to a "normal" mail? 但是,我必须在邮件中更改将其转换为“普通”邮件的内容? Change to multipart/alternative not work or is not enough. 更改为多部分/替代无效或不足。

  2. As an alternative i can create a new message with all infos captured from the NDR. 或者,我可以创建一条新消息,其中包含从NDR捕获的所有信息。 What is the best way to do this inside a SMTReceiveAgents.OnSubmitted Event? 在SMTReceiveAgents.OnSubmitted事件中执行此操作的最佳方法是什么?

  3. To create a copy from the public folder NDR for a normal user i tried args.Mailitem.Recipients.Add(new RoutingAddress("username@mydomain.com")) in the EndOfDataHandler. 要为普通用户从公用文件夹NDR创建副本,我尝试了args.Mailitem.Recipients.Add(new RoutingAddress("username@mydomain.com")) This doesnt work. 这行不通。 Why? 为什么?

Any answers, hints or solutions? 有任何答案,提示或解决方案吗?

Exchange 2007 NDRs to public Folders Exchange 2007 NDR到公用文件夹

Q1. Q1。 You do have to change it to multipart/alternative, but also, you should find "Content-Type: message/delivery-status" and change it to text/plain but it isnt required 您确实必须将其更改为多部分/替代,但是,您还应该找到“ Content-Type:消息/传递状态”并将其更改为文本/纯文本,但这不是必需的

Q2. Q2。 You could do this but your only options for the "original" message is to reject it to the sender, quarantine it or allow it..there is no delete / drop option.. but since it's going to a public folder it would be discarded. 您可以这样做,但“原始”邮件的唯一选择是拒绝发件人,隔离或允许它。.没有删除/删除选项..但是由于它将进入公用文件夹,因此将其丢弃。

If you go this route then enumerate the headers and body during EndOfHeadersEvent and then generate a new MailMessage object and include the headers and body from the original 如果走这条路线,则在EndOfHeadersEvent期间枚举标头和正文,然后生成一个新的MailMessage对象,并包括原始的标头和正文

Q3. Q3。 That should work.. only reason that I can see it wouldnt work is if you're trying to send to an external recipient / domain that isn't an accepted domain on the server..if that is what youre trying to do then you'll need to create a mail contact with your real external address and then CC the NDR to the external contact 那应该行..我能看到它行不通的唯一原因是,如果您尝试发送到服务器上不接受域的外部收件人/域,。如果这就是您要执行的操作,那么您需要使用您的真实外部地址创建一个邮件联系人,然后将NDR抄送给该外部联系人

Below is the code I was able to accomplish what you're trying to do. 以下是我能够完成您想要执行的操作的代码。 The reason I hook into onRcpt and onEndOfHeaders is to check if the recipient entered is the public folder address..I found it faster than enumerating the rcpt list at the end of the header 我挂在onRcpt和onEndOfHeaders上的原因是检查输入的收件人是否是公用文件夹地址。我发现它比枚举末尾的rcpt列表快

NDR保存到公用文件夹

void UserSendCounterSmtpReceiveAgent_OnRcptCommand(ReceiveCommandEventSource source, RcptCommandEventArgs e)
        {
            if(source == null || e == null)
            {
                return;
            }
            String recipient = e.RecipientAddress.ToString();
            if (recipient.Equals("publicfolder@domain.com"))
            {
                this.testOnEndOfHeaders = true;
            }

        }
        void UserSendCounterAgent_OnEndOfHeaders(ReceiveMessageEventSource source, EndOfHeadersEventArgs e)
        {
            if (source == null || e == null)
            {
                return;
            }

                if (testOnEndOfHeaders)
                {
                    this.testOnEndOfHeaders = false;
                    Header obj = e.Headers.FindFirst("Content-Type");
                    if (obj.Value.Equals(@"multipart/report"))
                    {
                        obj.Value = @"multipart/alternative";
                        e.MailItem.Recipients.Add(new RoutingAddress("forwardto@domain.com"));
                    }

                }

        }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM