By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,972 Members | 883 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,972 IT Pros & Developers. It's quick & easy.

sending emails with hebrew characters.

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a


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

P: n/a
> 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.