sending emails with hebrew characters.

  • Thread starter Thread starter Mr. x
  • Start date Start date
M

Mr. x

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 :)
 
Mr. x said:
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 = "(e-mail address removed)";
mail.From = "(e-mail address removed)";
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>
 
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 = "(e-mail address removed)";
mail.From = "(e-mail address removed)";
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 :)
 
Back
Top