확인. 나는이 해결책을 썼다. 그리고 나를 위해 그것은 충분하다 (하루에 최대 200) :
public class MyEmailTraceListener : EmailTraceListener
{
public const int MAXPER24HOURS = 200;
public static int counter =0;
public static DateTime counterReStarted = DateTime.Today;
private static bool CanLog()
{
bool returnValue = false;
DateTime today = DateTime.Today;
if (counter < MAXPER24HOURS)
{
counter++;
returnValue=true;
}
else if (today>counterReStarted)
{
counter = 0;
counterReStarted = today;
returnValue = true;
}
return returnValue;
}
public MyEmailTraceListener(string toAddress, string fromAddress, string subjectLineStarter, string subjectLineEnder, string smtpServer, int id, ILogFormatter formatter)
:base(toAddress, fromAddress, subjectLineStarter, subjectLineEnder, smtpServer, id, formatter)
{
}
public MyEmailTraceListener()
{
}
public override void TraceData(TraceEventCache eventCache, string source, TraceEventType eventType, int id, object data)
{
if (CanLog())
base.TraceData(eventCache, source, eventType, id, data);
}
}
public class MyTraceListenerAssembler : EmailTraceListenerAssembler
{
public override TraceListener Assemble(IBuilderContext context, TraceListenerData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
{
MyEmailTraceListenerData data = (MyEmailTraceListenerData)objectConfiguration;
return new MyEmailTraceListener(data.ToAddress, data.FromAddress, data.SubjectLineStarter, data.SubjectLineEnder, data.SmtpServer, data.SmtpPort, base.GetFormatter(context, data.Formatter, configurationSource, reflectionCache));
}
}
[Assembler(typeof(MyTraceListenerAssembler))]
public class MyEmailTraceListenerData : EmailTraceListenerData
{
}
또 다른 아이디어, 시간당 최대 10 개의 메일, sendmore 메일 인 경우 각 이메일을 하나의 이메일로 그룹화합니다. – Kiquenet