473,395 Members | 2,006 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,395 software developers and data experts.

Sending mail message with unicode text

Hello.
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>Test 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.TextReader textReader = new System.IO.StreamReader(fileName);
text = textReader.ReadToEnd();
textReader.Close();

// Assign message
MailMessage mailMessage = new MailMessage();
mailMessage.From = "so**@mail.com";
mailMessage.To = "so**@mail.com";
mailMessage.Subject = "Test";
mailMessage.Body = String.Format(text, "some UNICODE text");
mailMessage.BodyFormat = MailFormat.Html;
mailMessage.BodyEncoding = Encoding.Unicode;

// Send message
SmtpMail.SmtpServer = Settings.GetValue("SmtpServer");
SmtpMail.Send(mailMessage);
=================================

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.BodyEncoding = Encoding.Unicode; 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.


Nov 17 '05 #1
0 2151

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

Similar topics

2
by: Mr. x | last post by:
Hello, I am sending emails with Hebrew contents. When receiving emails - I cannot see the Hebrew characters (it is not outlook express configuration, because when receiving emails from friends -...
0
by: michi | last post by:
Hello :) When I execute following asp.net code **** Web.Mail.SmtpMail.SmtpServer = "squadron" Web.Mail.SmtpMail.Send("wwwmike@gmx.ch", "wwwmike@gmx.ch", "subj", "message") ****
1
by: David Dvali | last post by:
Hello. 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>Test...
6
by: Anuradha | last post by:
Dear All How can i send mails using vb.net Thanx all
2
by: =?Utf-8?B?QWRl?= | last post by:
HI All, I am encountering the following error when I try to send an email through a SMTP server. I believe the problem lies with the authentication part when the network crednetials are used,...
2
by: satnamsarai | last post by:
Using System.Net.Mail: Sometimes I get error 'failure sending mail. Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host.' Not sure how...
4
by: =?Utf-8?B?R3V5IENvaGVu?= | last post by:
Hi all I use: Dim message As New MailMessage(txtTo.Text, txtFrom.Text, txtSubject.Text, txtBody.Text) Dim emailClient As New SmtpClient(txtSMTPServer.Text) emailClient.Send(message) And its...
8
by: Marty | last post by:
I'm having issues sending an email to an "@page.nextel.com" email address. I can send to any other email address fine, but when I try the page.nextel.com it gives me this error: ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.