468,720 Members | 1,551 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,720 developers. It's quick & easy.

sending emails with hebrew characters.

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 -
I see hebrew, it is just sending by myself using *.aspx scripts).

In web.config I have the following :
<configuration>
<system.web>
<identity impersonate="true"/>
<globalization
requestEncoding="windows-1255"
responseEncoding="windows-1255"
fileEncoding="windows-1255"
culture="he-IL"
uiCulture="he-IL"
/>
</system.web>
</configuration>

In the aspx I have :

<html>

<head>

<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="TEXT/HTML; CHARSET=WINDOWS-1255">

</head>
.....

But is there anything else I should configure ?
Thanks :)
Nov 18 '05 #1
2 8528


Mr. x wrote:
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 -
I see hebrew, it is just sending by myself using *.aspx scripts).

In web.config I have the following :
<configuration>
<system.web>
<identity impersonate="true"/>
<globalization
requestEncoding="windows-1255"
responseEncoding="windows-1255"
fileEncoding="windows-1255"
culture="he-IL"
uiCulture="he-IL"
/>
</system.web>
</configuration>

In the aspx I have :

<html>

<head>

<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="TEXT/HTML; CHARSET=WINDOWS-1255">

</head>
....

But is there anything else I should configure ?


Those configurations are probably not in any way relevant. How do you
send the mail message? If you use
System.Web.Mail.MailMessage
to construct the email message then you can set
message.BodyEncoding
to specify the encoding for the message body.

For instance with the following ASP.NET page saved as UTF-8

<%@ Page Language="C#" %>
<%@ Import Namespace="System.Web.Mail" %>
<script runat="server">
void TestMailSending () {
MailMessage mail = new MailMessage();
mail.To = "XX*@XXX.XXX";
mail.From = "XX*@XXX.XXX";
mail.Subject = "Test to send mail with encoding Windows-1255";
mail.BodyFormat = MailFormat.Text;
mail.BodyEncoding = System.Text.Encoding.GetEncoding(1255);
mail.Body = "הו";
SmtpMail.SmtpServer = "XXX";
SmtpMail.Send(mail);
}
void Page_Load () {
TestMailSending();
Response.Write("<p>Sent one mail.</p>");
}
</script>

I get a text mail with the header

Content-Type: text/plain;
charset="windows-1255"

However I can't certify that sending Hebrew characters as Windows-1252
really works as I am not sure my newsreader handles that encoding correctly.

When I try to send the mail as UTF-8 however it works, the Hebrew
characters are displayed as far as I can tell:

<%@ Page Language="C#" %>
<%@ Import Namespace="System.Web.Mail" %>
<script runat="server">
void TestMailSending () {
MailMessage mail = new MailMessage();
mail.To = "XXX";
mail.From = "XXX";
mail.Subject = "Test to send mail with Hebrew characters with
encoding UTF-8";
mail.BodyFormat = MailFormat.Text;
mail.BodyEncoding = System.Text.Encoding.UTF8;
mail.Body =
"Test mail:\nHebrew letter HE \u05D4 \nHebrew letter VAV \u05D5";
SmtpMail.SmtpServer = "XXX";
SmtpMail.Send(mail);
}
void Page_Load () {
TestMailSending();
Response.Write("<p>Sent one mail.</p>");
}
</script>

--

Martin Honnen
http://JavaScript.FAQTs.com/

Nov 18 '05 #2
> Those configurations are probably not in any way relevant. How do you
send the mail message? If you use
System.Web.Mail.MailMessage
to construct the email message then you can set
message.BodyEncoding
to specify the encoding for the message body.

For instance with the following ASP.NET page saved as UTF-8

<%@ Page Language="C#" %>
<%@ Import Namespace="System.Web.Mail" %>
<script runat="server">
void TestMailSending () {
MailMessage mail = new MailMessage();
mail.To = "XX*@XXX.XXX";
mail.From = "XX*@XXX.XXX";
mail.Subject = "Test to send mail with encoding Windows-1255";
mail.BodyFormat = MailFormat.Text;
mail.BodyEncoding = System.Text.Encoding.GetEncoding(1255);
mail.Body = "";
SmtpMail.SmtpServer = "XXX";
SmtpMail.Send(mail);
}
void Page_Load () {
TestMailSending();
Response.Write("<p>Sent one mail.</p>");
}
</script>

I get a text mail with the header

Content-Type: text/plain;
charset="windows-1255"

However I can't certify that sending Hebrew characters as Windows-1252
really works as I am not sure my newsreader handles that encoding correctly.
When I try to send the mail as UTF-8 however it works, the Hebrew
characters are displayed as far as I can tell:

<%@ Page Language="C#" %>
<%@ Import Namespace="System.Web.Mail" %>
<script runat="server">
void TestMailSending () {
MailMessage mail = new MailMessage();
mail.To = "XXX";
mail.From = "XXX";
mail.Subject = "Test to send mail with Hebrew characters with
encoding UTF-8";
mail.BodyFormat = MailFormat.Text;
mail.BodyEncoding = System.Text.Encoding.UTF8;
mail.Body =
"Test mail:\nHebrew letter HE \u05D4 \nHebrew letter VAV \u05D5";
SmtpMail.SmtpServer = "XXX";
SmtpMail.Send(mail);
}
void Page_Load () {
TestMailSending();
Response.Write("<p>Sent one mail.</p>");
}
</script>


Thanks Martin - It works :)
Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Shmuel | last post: by
2 posts views Thread by Ben Kayam | last post: by
7 posts views Thread by Elie Nacache | last post: by
40 posts views Thread by Shmuel (Seymour J.) Metz | last post: by
2 posts views Thread by Etayki | last post: by
1 post views Thread by CARIGAR | last post: by
1 post views Thread by Oskars | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.