473,396 Members | 1,743 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

XML Encoding Issue

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;

}
Nov 11 '05 #1
1 1352
After this line:

mail.Body = strWriter.ToString();

You may save the string in a txt file and check if there are any invalid
charactors in it. Additionally, what is your mail client to open the email?
If you just send an email in HTML format (whitout convert from XML
document), can this work?
Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 11 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: lawrence | last post by:
Validator chokes on my pages now because I started sending an character encoding header of UTF-8 but the page is full of non UTF-8 characters. Anyway quick way to convert them? ...
4
by: Majed | last post by:
Hi , all I'm trying to write unicode to a file for another app (not developed with vs2003) to read it. I used StreamWriter with unicode encoding.but I was surprised that the streamwriter adds FFFE...
7
by: Mark | last post by:
Hi... I've been doing a lot of work both creating and consuming web services, and I notice there seems to be a discontinuity between a number of the different cogs in the wheel centering around...
11
by: Roger Leigh | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The program listed below demonstrates the use of wcsftime() and std::time_put<wchar_t> which is a C++ wrapper around it. (I know this isn't C; but...
2
by: Jan Agermose | last post by:
Im trying to send mail using this code: MailMessage mail = new MailMessage(); mail.From = "fejl@mydomain.com"; mail.Subject = "some subject"; mail.Priority = MailPriority.Normal;
2
by: MWells | last post by:
I've encountered an interesting issue regarding Url encoding that I'm hopeful someone can shed some light on. I have some vanity Url's that have to contain filename content, using the file...
5
by: James Wong | last post by:
Dear all, I've a web service function and it contains a parameter in System.Text.Encoding. I found that the data type of this parameter in caller application becomes MyWebSvcName.Encoding...
6
by: Franz Steinhaeusler | last post by:
Hello NG, a little longer question, I'm working on our project DrPython and try fix bugs in Linux, (on windows, it works very good now with latin-1 encoding). On Windows, it works good now,...
0
by: Janusz Nykiel | last post by:
I've stumbled upon unexpected behavior of the .NET 2.0 System.Xml.XmlWriter class when using it to write data to a binary stream (System.IO.Stream). If the amount of data is less than a certain...
5
by: =?Utf-8?B?TWFyaw==?= | last post by:
Hi... Have another thread going on in scripting.jscript trying to work around some deficiencies in the way IE and IIS interact. The nub of it is this: ASP.Net explicitly sets an output...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.