PDA

View Full Version : Trouble sending mails


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>

bruce
04-19-2007, 07:11 AM
Check the email content to see if you have bareLF.

http://kb.discountasp.net/article.aspx?id=10185


Bruce

DiscountASP.NET
www.DiscountASP.NET (http://www.DiscountASP.NET)

JanLimpens
04-19-2007, 07:16 AM
Sound very reasonable. There are no bare lf in my code, but they could be in the exception's error messages.
Investigating!

Thanks a lot,
Jan