Accent

F

Franck Diastein

Hi,

I have a txt file with some text I want to send via mail... The text
contains some words with accents... With my code, I receive the mail,
but letters with accent are missing :-(

What am I doing wrong ?

// Loading text file
private string MyBody(){
TextReader tr = new StreamReader(FilePath);
strBody = tr.ReadToEnd();
tr.Close();
}

//sending message
MailMessage _Mail = new MailMessage();
_Mail.To = m_strMailTo;
_Mail.Subject = "MyTest";
_Mail.From = m_strMailFrom;
_Mail.BodyEncoding = System.Text.Encoding.GetEncoding(1252);
_Mail.BodyFormat = MailFormat.Html;
_Mail.Priority = MailPriority.High;
_Mail.Body = m_MyBody() ;

TIA
 
M

Martin Honnen

Franck Diastein wrote:

I have a txt file with some text I want to send via mail... The text
contains some words with accents... With my code, I receive the mail,
but letters with accent are missing :-(

What am I doing wrong ?

// Loading text file
private string MyBody(){
TextReader tr = new StreamReader(FilePath);

It could improve things if you specify the encoding as the second
argument to the StreamReader constructor, of course you need to know the
encoding the file has for that.
 
F

Franck Diastein

OK, UTF7 did it :)

Thanx

Martin said:
Franck Diastein wrote:




It could improve things if you specify the encoding as the second
argument to the StreamReader constructor, of course you need to know the
encoding the file has for that.
 
F

Franck Diastein

Ok, I got it, but I have a little problem... Until now I was handling
line carriage replacing \r\n with <br> with no problem in HTML email...

But how do I handle line carriages in plain text message ?

Thanx
 
M

Molybedenum

Your accents may be extended ascii characters, which don't work too
well with HTML. I ran into this problem with characters 0x91 and
0x92, which are used in rich text.

I solved that problem by doing a string replacement of those
characters with their HTML hard-character equivalents. 0x91 would
then become ‘ and 0x92 would become ’.

-Mike

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top