I have a problem with sending Unicode text in mail message.
So what I do:
First of all I have some template file like this:
=============== =============== ===
<html>
<head><title>Te st Message</title></head>
<body>
<p>Hello {0}</p>
</body>
</html>
=============== =============== ===
This text will include Unicode text too.
Late I want to load this text and replace "{0}" with some value and send it
by mail.
then I do following:
=============== =============== ===
// Read message text from predefined file
System.IO.TextR eader textReader = new System.IO.Strea mReader(fileNam e);
text = textReader.Read ToEnd();
textReader.Clos e();
// Assign message
MailMessage mailMessage = new MailMessage();
mailMessage.Fro m = "so**@mail.com" ;
mailMessage.To = "so**@mail.com" ;
mailMessage.Sub ject = "Test";
mailMessage.Bod y = String.Format(t ext, "some UNICODE text");
mailMessage.Bod yFormat = MailFormat.Html ;
mailMessage.Bod yEncoding = Encoding.Unicod e;
// Send message
SmtpMail.SmtpSe rver = Settings.GetVal ue("SmtpServer" );
SmtpMail.Send(m ailMessage);
=============== =============== ===
Now about the problem:
when I got message sent by this code it looks something like this: (actually
this is an anothe mail)
=============== =============== ===
< h t m l > < h e a d > < t i t l e > R e g i s t e r i n g p r o p e r t y
< / t i t l e > < / h e a d > < b o d y > < p > < b > T h a n k y o u f o r
r e g i s t e r i n g y o u r p r o p e r t y w i t h R i g h t M o v i e ..
g e < / b > < / p > < p > Y o u r r e g i s t r a t i o n n u m b e r i s 1
9 3 3 9 6 a n d y o u s h o u l d q u o t e t h i s o n a n y c o r r e s p
o n d e n c e .. < / p > < p > Y o u r p r o p e r t y w i l l b e d i s p l
a y e d o n t h e R i g h t M o v i e .. g e w e b s i t e u n t i l 0 3 ..
1 2 .. 2 0 0 5 .. Y o u m a y r e n e w o r u p d a t e y o u r r e g i s t
r a t i o n a t a n y t i m e b y c l i c k i n g o n < a h r e f = " h t t
p : / / 2 1 3 .. 1 5 7 .. 2 0 1 .. 2 3 4 / R i g h t M o v e / P r o p e r t
y R e n e w .. a s p x ? r e g n u m = 1 9 3 3 9 6 " > h t t p : / / 2 1 3
... 1 5 7 .. 2 0 1 .. 2 3 4 / R i g h t M o v e / P r o p e r t y R e n e w
... a s p x ? r e g n u m = 1 9 3 3 9 6 < / a > .. < / p > < p > T h i s s e
r v i c e i s p r o v i d e d F R E E O F C H A R G E , s o p l e a s e t e
l l e v e r y o n e a b o u t R i g h t M o v i e .. g e .. < / p > < p > <
u > < b > D e t a i l s o f P r o p e r t y : < / b > < / u > < / p > < p >
< b > D i s p l a y e d U n t i l : < / b > 0 3 .. 1 2 .. 2 0 0 5 < b r > <
b > T y p e o f p r o p e r t y o r l a n d : < / b > ? ? ? ? ? < b r > < b
R o o m s : < / b > 4 ? ? ? ? ? < b r > < b > R e c e p t i o n r o o m s : < / b > 1 ? ? ? ? ? ? ? ? ? ? ? ? ? < b r > < b > A s k i n g P r i c e :
< / b > $ 9 9 .. 0 0 < b r > < b > H o u s e / A p p a r t m e n t # : < / b 9 < b r > < b > S t r e e t : < / b > ? ? ? 9 9 9 < b r > < b > D i s t r i c t a n d T o w n : < / b > ? ? ? ? ? ? ? < b r > < b > C o n t a c t : <
/ b > 9 9 9 < b r > < b > T e l e p h o n e : < / b > 9 9 9 < b r > < b > F
a x : < / b > < b r > < b > M o b i l e : < / b > < b r > < b > E - m a i l
: < / b > < a h r e f = " m a i l t o : d a v i d @ d s l .. g e " > d a v i
d @ d s l .. g e < / a > < b r > < b > E s t a t e A g e n t : < / b > ? ? ?
< b r > < b > P r o p e r t y D e s c r i p t i o n : < / b > 9 9 9 < b r >
< b > S t a t u s : < / b > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? < b r < b > E n t r y t y p e : < / b > ? ? ? ? ? ? ? ? ? ? ? < / p > < p > R i
g h t M o v i e .. g e a c c e p t s n o r e s p o n s i b i l i t y f o r t
h e a c c u r a c y o r a v a i l a b i l i t y o f t h e i n f o r m a t i
o n d i s p l a y e d o n i t s w e b s i t e a n d a c c e p t s n o l i a
b i l i t y f o r l o s s o f e a r n i n g s o r l o s s o f c a p i t a l
g a i n s t h r o u g h u s e o f i t s s e r v i c e s .. < / p > < / b o d
y > < / h t m l >
=============== =============== ===
When I don't use mailMessage.Bod yEncoding = Encoding.Unicod e; it send normal
mail but with "?" character instead Unicode symbols.
So how can I load from file then replace some values and send HTML format
Unicode text?
Thank you.