fu wing

Hello. I have faced the problem about automatically sending email in my system.

My website is allowed people type in chinese character and two of them are:

1. Seller Name

2. Seller Email Address

After people type in all their information , a email will be sent for them for reference.

Firstly, I found that while user type in chinese character in Seller Name Textbox, that email will become unrecognised code like this " P q C L " .

My coding is shown below:

MailMessage mailMessage = new MailMessage();

mailMessage.To.Add(new MailAddress(seller.Email, seller.Name));

It seems that I can't use chinese character as a displayName in MailAddress.

Is there any method

As I know, I can give encoding to the subject and body of mailMessage like this:

mailMessage.SubjectEncoding = Encoding.GetEncoding("big5");
mailMessage.BodyEncoding = Encoding.GetEncoding("big5");

Thanks

Fu Wing



Re: .NET Framework Networking and Communication Is there any method to assign encoding in mailaddress?

Eagle Tsui

I have the same problem but I can't solve it. I think Microsoft does not consider it so you need to search another compoment to do that. I think Microsoft need to have a long time learn java more. Java has already considered this problem but .Net does not.




Re: .NET Framework Networking and Communication Is there any method to assign encoding in mailaddress?

Dreedle

Email headers (where the email from/to etc adresses are placed) are required by SMTP to be 7-bit. However many applications ignore that and send 8-bit header information anyway and most SMTP servers will handle it correclty.

However, that does not help your situation because you need to transmit character encoding outwith 8-bits. I believe it can be done by escaping each character that requires encoding. Unfortunately I don't know how to do this myself.

Try googling for email RFC's (Request For Comments), all internet protocols and extensions are defined in these documents.

If there is a defined mechanism for email address escaping/encoding it will most likely be described there. For example, the RFC for SMTP is RFC822 (as far as I can remember) which will explain the SMTP protocol but does not deal with escaping header information. However, if an RFC exists detailing escaping/encoding it will most likely contain a reference to RFC822. RFC's tend to reference each other.

Good luck!






Re: .NET Framework Networking and Communication Is there any method to assign encoding in mailaddress?

Goodwill

new MailAddress(address, name, encoding)
the answer probably is too simple to be discussed.... seeing the thread have all sort of funny answers LOL
enjoy.





Re: .NET Framework Networking and Communication Is there any method to assign encoding in mailaddress?

fu wing

yes... i just tell you in MSN few minutes before. Please don't pretend that you find out the answer.

enjoy

 





Re: .NET Framework Networking and Communication Is there any method to assign encoding in mailaddress?

Goodwill

Yep :P But its really fun to see such answer... bet we should share it to everyone LOL
There's always moments we got blind anyway.





Re: .NET Framework Networking and Communication Is there any method to assign encoding in mailaddress?

Dreedle

I'm afraid I don't understand you "Goodwill"

What's funny about explaining a little of how SMTP works and where the details of how SMTP works can be found

I wish I were such an expert as you - but with manners.






Re: .NET Framework Networking and Communication Is there any method to assign encoding in mailaddress?

Goodwill

Dreedle,
Not to insult anybody. Its just sometime we didnt consult the basics before we post questions... believe me it always happens. Your information is good indeed, I have consult all these documents prior to know the answer, but if to answer this question, the fact is just check thru the overload list will got it. I guess we sometimes are being driven too far away by the question itself.

Again, indeed the RFCs are helpful- its just that we are like swimming all over the sea while the answer is really right next to us.

Try to think as the developer himself and then you will feel the fun I have its just a joke. Sorry to pin your nerve