JanLimpens
04-19-2007, 06:52 AM
Hello,
Somehow mails generated by the following method, don't get sent. It seems they get stuck in the queue (while other mails are being sent, so it's not that the server is not doing what it should. Anyone can spot the error? Or could it be the fact that it is called through global asax' Application_Error be the culprit? The Mailer.Send() methods sends every mail on the system sucessfully, but this one.
[quote]
publicstaticvoidSendErrorMail(Exceptione,stringsub ject,stringmessage)
{
try
{
StringBuilderbuffer=newStringBuilder();
if(!string.IsNullOrEmpty(message))
{
buffer.AppendLine('Message:');
buffer.AppendLine(message);
}
if(HttpContext.Current.Request!=null)
{
buffer.AppendFormat(uriFormat,HttpContext.Current. Request.Url.PathAndQuery);
}
stringeSubject=string.Empty;
if(HttpContext.Current.Server!=null)
{
eSubject=e.GetBaseException().Message;
if(e!=null)
{
while(e!=null)
{
buffer.AppendFormat(exceptionFormat,
e.GetType().Name,
e.Message,
e.StackTrace);
buffer.AppendLine();
e=e.InnerException;
}
}
}
MailMessagemailMessage=newMailMessage();
mailMessage.Body=buffer.ToString();
mailMessage.Subject='Error@'+Properties.Settings.D efault.ApplicationID+'('+DateTime.Now.ToShortDateS tring()+')'+subject+'('+eSubject+')';
mailMessage.From=newMailAddress(from);
mailMessage.To.Add(newMailAddress(Properties.Setti ngs.Default.ErrorEmail));
mailMessage.IsBodyHtml=false;
Mailer.Send(mailMessage);
}
catch{}
}</CODE>
Somehow mails generated by the following method, don't get sent. It seems they get stuck in the queue (while other mails are being sent, so it's not that the server is not doing what it should. Anyone can spot the error? Or could it be the fact that it is called through global asax' Application_Error be the culprit? The Mailer.Send() methods sends every mail on the system sucessfully, but this one.
[quote]
publicstaticvoidSendErrorMail(Exceptione,stringsub ject,stringmessage)
{
try
{
StringBuilderbuffer=newStringBuilder();
if(!string.IsNullOrEmpty(message))
{
buffer.AppendLine('Message:');
buffer.AppendLine(message);
}
if(HttpContext.Current.Request!=null)
{
buffer.AppendFormat(uriFormat,HttpContext.Current. Request.Url.PathAndQuery);
}
stringeSubject=string.Empty;
if(HttpContext.Current.Server!=null)
{
eSubject=e.GetBaseException().Message;
if(e!=null)
{
while(e!=null)
{
buffer.AppendFormat(exceptionFormat,
e.GetType().Name,
e.Message,
e.StackTrace);
buffer.AppendLine();
e=e.InnerException;
}
}
}
MailMessagemailMessage=newMailMessage();
mailMessage.Body=buffer.ToString();
mailMessage.Subject='Error@'+Properties.Settings.D efault.ApplicationID+'('+DateTime.Now.ToShortDateS tring()+')'+subject+'('+eSubject+')';
mailMessage.From=newMailAddress(from);
mailMessage.To.Add(newMailAddress(Properties.Setti ngs.Default.ErrorEmail));
mailMessage.IsBodyHtml=false;
Mailer.Send(mailMessage);
}
catch{}
}</CODE>