I've sent mail via "CDO.Message" without any problem. Now I try to use with UTF8 (FW_Unicode(.T.)), it got the problem. Thai Language is unreadable in Email program such as Outlook or Gmail on browser as picture.
![Image](https://i.postimg.cc/3xLDQMJL/UTF8-mail.png)
This is my code. The sending method is no problem but It look like Outlook or Gmail do not support Unicode. I do not understand.
Code: Select all | Expand
cHtml:='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">'+CRLF
cHtml+='<HTML><HEAD>'+CRLF
cHtml+='<META content="text/html; charset=utf-8" http-equiv=Content-Type>'+CRLF
cHtml+='<META name=GENERATOR content="MSHTML 8.00.6001.18783">'+CRLF
cHtml+='<STYLE></STYLE>'+CRLF
cHtml+='</HEAD>'+CRLF
cHtml+='<BODY bgColor=#ffffff>'
cHtml+='<DIV>'
cHtml += cMsg+'<br>'
cHtml += '</DIV></BODY></HTML>'
?cHtml
TRY
oEmailCfg := CREATEOBJECT( "CDO.Configuration" )
WITH OBJECT oEmailCfg:Fields
:Item( "http://schemas.microsoft.com/cdo/configuration/smtpserver" ):Value := cSmtp // "smtp.gmail.com"
:Item( "http://schemas.microsoft.com/cdo/configuration/smtpserverport" ):Value := iif(lSSL,465,25) // 465 SSL
:Item( "http://schemas.microsoft.com/cdo/configuration/sendusing" ):Value := 2 // Remote SMTP = 2, local = 1
:Item( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate" ):Value := iif(lAuthen,.T.,.F.) // .T.
:Item( "http://schemas.microsoft.com/cdo/configuration/smtpusessl" ):Value := lSSL // .T.
:Item( "http://schemas.microsoft.com/cdo/configuration/savesentitems" ):Value := lSave
:Item( "http://schemas.microsoft.com/cdo/configuration/sendusername" ):Value := cSender // "hotel@gmail.com"
:Item( "http://schemas.microsoft.com/cdo/configuration/sendpassword" ):Value := cPass // Password
:Item( "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"):Value := 30
:Update()
END WITH
CATCH oError
if lMsgInfo
MsgAlert("Could not setting message" +CRLF+ ;
"Error : " + TRANSFORM(oError:GenCode, NIL) +CRLF+ ;
"SubCode : " + TRANSFORM(oError:SubCode, NIL) +CRLF+ ;
"OSCode : " + TRANSFORM(oError:OsCode, NIL) +CRLF+ ;
"SubSystem : " + TRANSFORM(oError:SubSystem, NIL) +CRLF+ ;
"Message : " + oError:Description )
else
nSuccess := 0
end
cErrorDesc := if(IsInternet(),rtrim(oError:Description),'Internet Connection Fail')
END
oError:=NIL
TRY
oEmailMsg := CREATEOBJECT ( "CDO.Message" )
WITH OBJECT oEmailMsg
:Configuration := oEmailCfg
:From := chr(34)+cDisplay+" "+chr(34)+ "<"+cReply+">" // cSender // This will be displayed in the From (The email id does not appear)
if !empty(cTo) // check no receiver for Mail advertising, it will send to BCC instead
:To := cTo // <----- Place your email address
end
if !empty(cBCC) // check no receiver for Mail advertising, it will send to BCC instead
:Bcc := cBCC
end
:Subject := rtrim(cSubject) // "Email Test Message from GMail"
:ReplyTo := cReply
:MDNRequested := .F. // .F. anyone use without warning
if !empty(cAttach)
:AddAttachment(cAttach)
end
:BodyPart:Charset := "utf-8"
:HTMLBody := cHtml
END WITH
oEmailMsg:Send()
CATCH oError
nSuccess := 0
if lMsgInfo
MsgAlert("Could not send message" + CRLF+ ;
"Error : " + TRANSFORM(oError:GenCode, NIL) + CRLF+;
"SubCode : " + TRANSFORM(oError:SubCode, NIL) + CRLF+ ;
"OSCode : "+ TRANSFORM(oError:OsCode, NIL) + CRLF +;
"SubSystem : " + TRANSFORM(oError:SubSystem, NIL) + CRLF+ ;
"Message : " + oError:Description )
end
cErrorDesc := if(IsInternet(),rtrim(oError:Description),'Internet Connection Fail')
END
Thank you in advance for any help or suggestion.