Send email containing multilingual text

sivachirravuri
sivachirravuri used Ask the Experts™
on
I have this piece of code in an .asp file. I generate E-mail subject/body through XML tags and I send an email through ASP.
When I get the tags from XML it has different English/greek/french/german characters. Problem is I need to send mail in different languages at same time. After sending emails, sometimes few characters appear in the email as ????? or !!!!! or very confused characters.

Can anyone say exact reason why this is happening?
<meta http-equiv='Content-type' content='text/html;charset=UTF-8'>
 
Set myMail=CreateObject("CDO.Message")
myMail.Subject="my subject"
myMail.From=Request("email")
myMail.To="myemail@mail.com"
Dim Body
Body = Body & "Name: " & Request("name") & VbCrLf
Body = Body & "E-mail: " & Request("email") & VbCrLf
Body = Body & "-----" & VbCrLf
Body = Body & Request("the_message") & VbCrLf
 
myMail.TextBody=Body
 
myMail.Send
set myMail=nothing

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Wayne BarronAuthor, Web Developer
Top Expert 2009

Commented:
Add this to your code

myMail.BodyPart.Charset = "utf-8"
myMail.TextBodyPart.Charset = "utf-8"
myMail.HTMLBodyPart.Charset = "utf-8"

Good Luck
Carrzkiss
sivachirravuriTeam Lead

Author

Commented:
Following is there from before
myMail.BodyPart.Charset = "utf-8"

I am getting following error "The requested body part was not found in this message" after I include
myMail.TextBodyPart.Charset = "utf-8"
myMail.HTMLBodyPart.Charset = "utf-8"


sivachirravuriTeam Lead

Author

Commented:
Thanks for you Reply.
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Wayne BarronAuthor, Web Developer
Top Expert 2009

Commented:
did you try it without adding in these
myMail.TextBodyPart.Charset = "utf-8"
myMail.HTMLBodyPart.Charset = "utf-8"
??

Carrzkiss
Author, Web Developer
Top Expert 2009
Commented:
Got it I think??

The reason for the error, is that it had to find the Body, and depending on where
The lines where located at, it could not find the body.
So setting in your case, the TextBodyPart
Below your   TextBody
Will allow it to see the body.

You are using HTMLBody
So you do not need to use the HTMLBodyPart
In this code issue.

Hope that helps?
Carrzkiss
<meta http-equiv='Content-type' content='text/html;charset=UTF-8'>
 
Set myMail=CreateObject("CDO.Message")
myMail.Subject="my subject"
myMail.From=Request("email")
myMail.To="myemail@mail.com"
Dim Body
Body = Body & "Name: " & Request("name") & VbCrLf
Body = Body & "E-mail: " & Request("email") & VbCrLf
Body = Body & "-----" & VbCrLf
Body = Body & Request("the_message") & VbCrLf
myMail.BodyPart.Charset = "utf-8"  
myMail.TextBody=Body
myMail.TextBodyPart.Charset = "utf-8" 
'myMail.HTMLBodyPart.Charset = "utf-8" ' Use this if you have HTMLBody
myMail.Send
set myMail=nothing

Open in new window

sivachirravuriTeam Lead

Author

Commented:
Above solution help to some extent but still sometime email body is including an "!" and space when the body is bigger (around 750+ characters). The issue is occuring both in .textbody and .htmlbody formats.
e.g. 'poin! ts' instead of 'points'
sivachirravuriTeam Lead

Author

Commented:
I observered that it may be problem because of length. When I remove few words in the mail, this "! " moves backward that many characters.
it's very wierd. I don't understand what is problem with length? Any suggession please.
Wayne BarronAuthor, Web Developer
Top Expert 2009

Commented:
I really have no idea what would be causing this issue.
I have checked to see if I can find a restriction or length issue with the charset
And I am not find nothing on it.

I will see if I can find some more info later on today or tomorrow when I have the spare time.

Carrzkiss
sivachirravuriTeam Lead

Author

Commented:
Thanks a ton for the solution. Problem is solved by giving Charset to TextBodyPart & HTMLBodypart, just before send & some other part of code.
Wayne BarronAuthor, Web Developer
Top Expert 2009

Commented:
Cool, so adding it in to just the right place made it all work out.
That is awesome.

Glad that you have it working now.
Keep up the great coding.

Carrzkiss

Author Comments:
Thanks a ton for the solution. Problem is solved by giving Charset to TextBodyPart & HTMLBodypart, just before send & some other part of code.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial