请帮助MS Exchange传输代理代码替换电子邮件主题行。 [英] Please help with MS Exchange Transport Agent code to replace email Subject line.

查看:78
本文介绍了请帮助MS Exchange传输代理代码替换电子邮件主题行。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个自定义Exchange运输代理。代码如下。它应该替换特定接收者的消息主题行。我在Exchange 2010服务器上安装了
,但它没有做任何事情。谢谢。



使用System; 
使用System.Collections.Generic;
使用System.Linq;
使用System.Text;
使用Microsoft.Exchange.Data.Transport.Smtp;
使用Microsoft.Exchange.Data.Transport;
使用Microsoft.Exchange.Data.Transport.Routing;
使用System.Diagnostics;
使用System.Globalization;

命名空间MyReportShareAgent
{

公共密封类MyAgentFactory:RoutingAgentFactory
{
公众覆盖RoutingAgent CreateAgent(SMTPSERVER服务器)
{
RoutingAgent myAgent = new MyRoutingAgent();
返回myAgent;
}
}

公共类MyRoutingAgent:RoutingAgent
{




public MyRoutingAgent ()
{
//订阅不同的事件
base.OnSubmittedMessage + = new SubmittedMessageEventHandler(SRoutingAgent_OnSubmittedMessage);
}


空隙SRoutingAgent_OnSubmittedMessage(SubmittedMessageEventSource源,QueuedMessageEventArgs E)
{




if(e.MailItem.Message.To.Equals(" report@company.com"))
{
try
{
e.MailItem.Message.Subject = " PP" + GetWeekNumber(DateTime.Now);

}
catch(例外情况除外)
{

}
}


}


public static String GetWeekNumber(DateTime dtPassed)
{
CultureInfo ciCurr = CultureInfo.CurrentCulture;
int weekNum = ciCurr.Calendar.GetWeekOfYear(dtPassed,CalendarWeekRule.FirstFourDayWeek,DayOfWeek.Thursday);
String weekString =((weekNum + 1)/ 2).ToString();
返回weekString;
}

}
}






sean zhang签名

解决方案


请参阅下面提到的文章 以解决Exchange传输代理问题:


如何编写Exchange 2007传输代理商

http://blogs.technet.com/b/exchange/archive/2006/12/04/3397431。 aspx

部分: 运输代理商疑难解答


另外,看看您是否能够使用下面提到的文章中发布的样本传输代理:


示例Exchange 2007传输代理 - 将组的名称添加到主题行

http://blogs.technet.com/ b / exchange / archive / 2008/06/25 / sample-exchange-2007-transport-agent-add-the-name-of-group-to-subject-line.aspx


注意,


Brij Raj Singh

Brijs Blogging ...超越显而易见性


I have created a custom Exchange Transport Agent. The code is below. It is supposed to replace the message Subject line for a particula recepient. I have installed it on Exchange 2010 server but it doesn't do anything. Thank you.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Exchange.Data.Transport.Smtp;
using Microsoft.Exchange.Data.Transport;
using Microsoft.Exchange.Data.Transport.Routing;
using System.Diagnostics;
using System.Globalization;

namespace MyReportShareAgent
{

    public sealed class MyAgentFactory : RoutingAgentFactory
    {
        public override RoutingAgent CreateAgent(SmtpServer server)
        {
            RoutingAgent myAgent = new MyRoutingAgent();
            return myAgent;
        }
    }

    public class MyRoutingAgent : RoutingAgent
    {




        public MyRoutingAgent()
        {
            //subscribe to different events 
            base.OnSubmittedMessage += new SubmittedMessageEventHandler(SRoutingAgent_OnSubmittedMessage);
        }


        void SRoutingAgent_OnSubmittedMessage(SubmittedMessageEventSource source, QueuedMessageEventArgs e)
        {




            if (e.MailItem.Message.To.Equals("report@company.com"))
            {
                try
                {
                    e.MailItem.Message.Subject = "PP" + GetWeekNumber(DateTime.Now);

                }
                catch (Exception except)
                {

                }
            }

            
        }


        public static String GetWeekNumber(DateTime dtPassed)
        {
            CultureInfo ciCurr = CultureInfo.CurrentCulture;
            int weekNum = ciCurr.Calendar.GetWeekOfYear(dtPassed, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Thursday);
            String weekString = ((weekNum + 1) / 2).ToString();
            return weekString;
        }

    }
}



sean zhang signature

解决方案

Hi,

Please refer to the below mentioned article for troubleshooting Exchange Transport Agents:

How to write Exchange 2007 transport agents
http://blogs.technet.com/b/exchange/archive/2006/12/04/3397431.aspx
Section: Troubleshooting Transport Agents

Also, see if you are able to use the sample transport agent posted on the article mentioned below:

Sample Exchange 2007 transport agent - add the name of the group to subject line
http://blogs.technet.com/b/exchange/archive/2008/06/25/sample-exchange-2007-transport-agent-add-the-name-of-the-group-to-subject-line.aspx

Regard,

Brij Raj Singh
Brijs Blogging... Looking Beyond the Obvious


这篇关于请帮助MS Exchange传输代理代码替换电子邮件主题行。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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