a C#program sending a message in Russian

stat5257402

Hello anybody. I'm have a problem with programm sending a message in Russian in c#.
I wrote small program sending a English message here :
MailMessage mes = new MailMessage;
mes.From = "myisp.net";
mes.To = "mail.ru";
mes.Subject = "TEST";
mes.Body = "go";
SmtpMail.SmtpServer = "mail.ru";
SmtpMail.Send(mes);
It work okey. But if i assign mes.Body = "АВАВфцукцуЭ" then mail box mail.ru receive a empty message, not needed message 'АВАВфцукцуЭ'.
Have anybody met the problem? Help me.

maggi14

I suppose message "АВАВфцукцуЭ" not to be Russian.

Ivan8209

Keywords: MIME.
---
Q22: and what does not suck then?
A22: Microsoft vacuum-cleaner.

stat5257402

I suppose message "АВАВфцукцуЭ" not to be Russian.
why ?

stat5257402

the original problem i want to solve is to read the text file ( in russian) and send it to an email.

Helga87

Try to set the following properties of MailMessage:
message.BodyEncoding =  System.Text.Encoding.UTF8;
message.SubjectEncoding = System.Text.Encoding.UTF8;

stat5257402

MailMessage mes = new MailMessage;
mes.From = "myisp.net";
mes.To = "mail.ru";
mes.Subject = "TEST";
mes.Body = "ав";
mes.BodyEncoding = System.Text.Encoding.UTF8;
SmtpMail.SmtpServer = "172.16.39.1";
SmtpMail.Send(mes);
and i received an empty message

Ivan8209

> mes.Body = "ав";
> mes.BodyEncoding = System.Text.Encoding.UTF8;
What's the encoding of "ав" string literal?
You should have converted this string into UTF-8.
---
Q22: and what does not suck then?
A22: Microsoft vacuum-cleaner.

stat5257402

how to convert the string to UTF-8. Please let me know.

Helga87

You should have converted this string into UTF-8.
You do not know .net, . He should not.

Helga87

net 2.0:
      SmtpClient client = new SmtpClient("smtp.mail.ru");
client.Credentials = new NetworkCredential("myaccount", "mypassword");
MailMessage mes = new MailMessage(
new MailAddress("mail.ru"
new MailAddress("dmail.ru";
mes.Subject = "TEST";
mes.Body = "ав";
mes.BodyEncoding = System.Text.Encoding.UTF8;

client.Send(mes);

It works fine.

Ivan8209

Well, then s/he has to STFM.
Keywords: locale, native language support, internalization, multilinguization &c.
---
Q22: and what does not suck then?
A22: Microsoft vacuum-cleaner.

Helga87

Keywords: KONTPA, lamer
.net строки хранит в unicode и преобразует к указанной кодировке текст сам. Проблема у чувака скорее всего в том, что utf-8 режется тем же 172.16.39.1

markmsk

Keywords: KONTPA, lamer
+1

Ivan8209

> KONTPA
Да уж, действительно ламер.
> Проблема у чувака скорее всего в том, что utf-8 режется тем же 172.16.39.1
.Net не знает про base64?
---
...Я работаю антинаучным аферистом...

stat5257402

SmtpClient client = new SmtpClient("smtp.mail.ru");
client.Credentials = new NetworkCredential("myaccount", "mypassword");
MailMessage mes = new MailMessage(
new MailAddress("mail.ru"
new MailAddress("dmail.ru";
mes.Subject = "TEST";
mes.Body = "ав";
mes.BodyEncoding = System.Text.Encoding.UTF8;

client.Send(mes);
i use Vs.net 2003

Helga87

i use Vs.net 2003
Why?
Тем не менее, try to change smpt server and send a message via smtp.mail.ru.

stat5257402

the ip is ip of server.hackers . it works properly.

stat5257402

net 2.0 means that visual studio 2005.

Helga87

Ага. И в чем проблема использовать VS 2005?

Helga87

the ip is ip of server.hackers . it works properly.
Попытайся через него отправить письмо в utf-8 из The Bat или Outlook. Если получится отправить, значит, проблема в коде. Не получится — в сервере.

stat5257402

SmtpClient is not available in .net 2.0

bobby

SmtpClient is not available in .net 2.0
What makes you think so?

stat5257402

oh, i'm sorry. i don't know the class is in System.Net.Mail. I'm sorry.
Now I have another problem.
I have a file a.txt. The content of this file is in russian.
авыаываывавыаываыва.
I want to show it in console in russian. But it does not work.
StreamReader f = File.OpenText("a.txt");
System.Console.WriteLine(f.ReadToEnd;
f.Close;
But there is nothing in monitor after running it.
Help me.

vook

You're just using a wrong tool. Use Common Lisp, like all smart people do . It took me 5 minutes to download a library (CL-SMTP install it, and write a one-liner that sends a message to one of my e-mails:

(cl-smtp:send-email "gw.local" "email1" "email2" "Превед!" "Превед, как дела?")

It worked so well, I was surprised myself. Ditch NET, it's Unicode support is probably FUBAR, so it screws Russian text.

stat5257402

I just use C# because after reading the text file in russian i will send it to an email. The problem sending a russian message to email is solved.
Using C# to send a message is easy to code.

Landstreicher

lol! я угораю с этого треда

Ivan8209

Осталось посоветовать операционную систему.
---
Q13: wtf XXX YYY?
A13: Че?

Helga87

Судя по всему, у тебя файл в кодировке отличной от utf-8. По-умолчанию StreamReader использует именно эту кодировку для того, чтобы прочитать текст. Чтобы все заработало, необходимо явно указать кодировку. Если предположить, что файл в кодировке cp1251, код, выводящий на консоль содержимое файла, будет выглядеть так:
 
Console.WriteLine(File.ReadAllText("lala.txt", Encoding.GetEncoding(1251;  

Ivan8209

That's because you don't know about mail(1) and popen(3).
---
Q43: А какое предназначение у винды?
A43: bsod

stat5257402

code:-------------------------------------------------------------------------------- SmtpClient client = new SmtpClient("smtp.mail.ru");
client.Credentials = new NetworkCredential("myaccount", "mypassword");
MailMessage mes = new MailMessage(
new MailAddress("mail.ru"
new MailAddress("dmail.ru";
mes.Subject = "TEST";
mes.Body = "ав";
mes.BodyEncoding = System.Text.Encoding.UTF8;

client.Send(mes);
it does not work fine

Helga87

У меня работает. Сделай тестовый проект и дай ссылку на него. Так будет проще всего понять, почему у тебя ничего не работает.

evgen5555

NetworkCredential("myaccount", "mypassword");

Just supply a valid account
Оставить комментарий
Имя или ник:
Комментарий: