Hi, All,
I'm trying to take an xmldocument and output it to html (email). Everything
seems to work when I capture the XmlDocument to a StringWriter and past that
to the Mail objects body. When I receive the email its blank, but the
source shows complete...perfect HTML... WHY??? I think it's an encoding
problem, below is the complete method...
Thanks,
Neil Guyette
public bool Send(XmlDocument xDoc, string xslFilePath)
{
XslTransform xslTran = new XslTransform();
XmlDocument xDocFinal = new XmlDocument();
xslTran.Load(xslFilePath);
xDocFinal.Load(xslTran.Transform(xDoc, null,(XmlResolver)null));
// Create the string writer
StringWriter strWriter = new StringWriter();
xDocFinal.Save(strWriter);
MailMessage mail = new MailMessage();
mail.From = ConfigurationSettings.AppSettings["MailerSender"];
mail.Priority = MailPriority.High;
mail.To = _EmailAddr;
mail.Subject = _Subject;
mail.Body = strWriter.ToString();
mail.BodyFormat = MailFormat.Html;
SmtpMail.SmtpServer =
ConfigurationSettings.AppSettings["MailerServer"];
SmtpMail.Send(mail);
return true;
}
return false;
}