Wednesday, January 28, 2009

ASP .. CDO.Message .. Charset (or Encoding) utf-8 unicode

1.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>


2.
Its the 8bit transfer encoding on the html part which is causing the
problem. It should be quoted-printable like the plain text alternative
part. I've come acroess this before on Win 2003 machines where CDO chooses
8bit encoding despite it being an in appropriate encoding for sending via
SMTP.

Trying adding this line before sending:-

..HTMLBodyPart.ContentTransferEncoding = "quoted-printable"


' ### sendMail to Multiple people. Separated by ; semi-colon (no spare in between)
Function sendMail( sender, mailList, subject, strBody)
bodyformat = 0 ' 0:HTML, 1:text
mailformat = 0 ' 0:MIME, 1:text

set objmail = Server.CreateObject("CDO.Message")
objmail.From = sender
' objmail.TextBodyFormat = bodyformat
' objmail.MailFormat = mailformat
objmail.Subject = subject

'objmail.To = mailList
objmail.Bcc = mailList
'objmail.Cc = ""


objmail.HTMLBody = strBody
objMail.HTMLBodyPart.Charset = "utf-8"
objMail.HTMLBodyPart.ContentTransferEncoding = "quoted-printable"

'objmail.TextBody = strBody
'objMail.TextBodyPart.Charset = "utf-8"
'objMail.TextBodyPart.ContentTransferEncoding = "quoted-printable"

objmail.Send()

set objmail=Nothing
'Response.Write "Done! mail has been sent!" & strBody & "

" & mailList
'sendMailx = "done!"
End Function

No comments: