Last post Aug 23, 2008 04:26 AM by anov
Dec 08, 2007 02:09 PM|cgi_pro|LINK
I'm using System.Net.Mail to send emails to my mailing list.
Dim MyMailMessage As New MailMessage()
MyMailMessage.SubjectEncoding = System.Text.Encoding.Default
MyMailMessage.BodyEncoding = System.Text.Encoding.Default
This way, when the recepient receives my email that I've sent him, he will be able to read the message in Arabic characters without the need to manually do the changes in Internet Explorer (by going to view > Encoding > Arabic (Windows))
However, those encoding settings take care of the subject and body, while the (from) gets received by the recepient in non-readable characters.
How do I take care of this (from) the same way I did with the (subject) and (body)??
Dec 08, 2007 04:33 PM|mr.aspdotnet|LINK
Where are you reading you email content from i.e. email body text.
Dec 09, 2007 06:50 AM|cgi_pro|LINK
The Email body and subject I read them from form text fields
While the (from) I read it from the web.config
Dec 09, 2007 08:37 AM|mr.aspdotnet|LINK
You need to make sure that you are reading your text from file using the right encoding. I suppose you are using stream reader so you need to read your file like this:
StreamReader sr =
Also make your email encoding to be UTF-8 like this
It should work fine.
Dec 09, 2007 02:11 PM|cgi_pro|LINK
As I mentioned earlier, I'm reading my email body and subject from an html-coded form text input field, such as:
<input type='text' name='MsgSubject' value='Some Subject Value The User has inputted'>
<input type='text' name='MsgBody' value='Some Body Value The User has inputted'>
So, when the user submits this form, I read and set the encoding of those two values like this:
mMailMessage.Subject = Request.Form("MsgSubject")
mMailMessage.Body = Request.Form("MsgBody")
mMailMessage.SubjectEncoding = System.Text.Encoding.Default
mMailMessage.BodyEncoding = System.Text.Encoding.Default
When I check the received email, I find that both the subject and body of the email message show in Arabic characters, which is what I want. However, what doesn't show in Arabic (but in some weird characters) is the (From).
The way I read the (From) in my application is like this:
Dim FromName As String = System.Configuration.ConfigurationSettings.AppSettings("AdminDisplayName")
Dim FromEmail As String = System.Configuration.ConfigurationSettings.AppSettings("AdminEmailAddress")
Dim MyFrom As String = FromName + "<" + FromEmail + ">"
mMailMessage.From = New MailAddress(MyFrom)
That's because I already have the following defined in my web.config:
<add key="AdminDisplayName" value="Some Arabic Characters" />
<add key="AdminEmailAddress" value="firstname.lastname@example.org" />
But I can't encode this (From) field like I did for the body and subject of the email, because there is no such a
mMailMessage.FromEncoding = System.Text.Encoding.Default
This is the problem I'm facing here. So, what to do in this case?
Aug 23, 2008 04:26 AM|anov|LINK
I am faced this problem in last week,
I decided this is a mail server problem but when i testing in another pop3 mail server this weird characters appended again.
And when i changed mail client with my gmail account, encoding problem was gone.
And test other computers, this problem only my machine (mail client).
Your (or who googling and came here) problem may be a mail-client (Thunderbird, Outlook) based.