Problem with the encoding of a CDO subject

I

ioannisd

Hi,

I am sending emails though CDO (using ASP). In my mail I have Greek
characters which are not being displayed correctly unless I do
Server.HTMLEncode(textmsg) before submitting it to CDO (and that works
fine!). My problem is that I cannot get the subject of the email to
work with Greek characters.

I guess there must a property for the encoding but I have not been
able to find out which one it is....

This is my ASP code....

'===========================================

Function sendMail(recipient, subject, msg)
Response.Write(Recipient)
Response.Write("<br>")
Response.Write(subject)
Response.Write("<br>")
Response.Write(msg)
Response.Write("<br>")



Const cdoSendUsingPickup = 1
Const cdoSendUsingPort = 2 'Must use this to use Delivery
Notification
Const cdoAnonymous = 0
Const cdoBasic = 1 ' clear text
Const cdoNTLM = 2 'NTLM
'Delivery Status Notifications
Const cdoDSNDefault = 0 'None
Const cdoDSNNever = 1 'None
Const cdoDSNFailure = 2 'Failure
Const cdoDSNSuccess = 4 'Success
Const cdoDSNDelay = 8 'Delay
Const cdoDSNSuccessFailOrDelay = 14 'Success, failure or delay

set objMsg = CreateObject("CDO.Message")
set objConf = CreateObject("CDO.Configuration")

Set objFlds = objConf.Fields
With objFlds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") =
cdoSendUsingPort
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") =
"smtp.mail.yahoo.com"
.Item("http://schemas.microsoft.com/cdo/configuration/
smtpserverport") = 465
.Item("http://schemas.microsoft.com/cdo/configuration/
smtpconnectiontimeout") = 20
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") =
True
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername")
= "<MYUSERNAME>"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword")
="<MYPASSWORD>"
.Item("http://schemas.microsoft.com/cdo/configuration/
smtpauthenticate") = 1

.Update
End With

'strBody = "This is a sample message." & vbCRLF
'strBody = strBody & "It was sent using CDO." & vbCRLF
strBody = msg & vbCRLF

With objMsg
Set .Configuration = objConf
.To = recipient
.From = "<MY EMAIL>"
.Subject = subject

.HTMLBody = "<br>THIS IS HTMLBODY: " & strBody
.Fields.update

.Send
End With

sendEmail = err.Number

for each field in objMsg.fields
Response.Write("<B>"&field.name&"</B> : " & field.value & "<BR>")
next



Response.Write("======================================<BR>")

End Function
 
A

Anthony Jones

ioannisd said:
Hi,

I am sending emails though CDO (using ASP). In my mail I have Greek
characters which are not being displayed correctly unless I do
Server.HTMLEncode(textmsg) before submitting it to CDO (and that works
fine!). My problem is that I cannot get the subject of the email to
work with Greek characters.

I guess there must a property for the encoding but I have not been
able to find out which one it is....

This is my ASP code....

'===========================================

Function sendMail(recipient, subject, msg)
Response.Write(Recipient)
Response.Write("<br>")
Response.Write(subject)
Response.Write("<br>")
Response.Write(msg)
Response.Write("<br>")



Const cdoSendUsingPickup = 1
Const cdoSendUsingPort = 2 'Must use this to use Delivery
Notification
Const cdoAnonymous = 0
Const cdoBasic = 1 ' clear text
Const cdoNTLM = 2 'NTLM
'Delivery Status Notifications
Const cdoDSNDefault = 0 'None
Const cdoDSNNever = 1 'None
Const cdoDSNFailure = 2 'Failure
Const cdoDSNSuccess = 4 'Success
Const cdoDSNDelay = 8 'Delay
Const cdoDSNSuccessFailOrDelay = 14 'Success, failure or delay

set objMsg = CreateObject("CDO.Message")
set objConf = CreateObject("CDO.Configuration")

Set objFlds = objConf.Fields
With objFlds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") =
cdoSendUsingPort
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") =
"smtp.mail.yahoo.com"
.Item("http://schemas.microsoft.com/cdo/configuration/
smtpserverport") = 465
.Item("http://schemas.microsoft.com/cdo/configuration/
smtpconnectiontimeout") = 20
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") =
True
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername")
= "<MYUSERNAME>"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword")
="<MYPASSWORD>"
.Item("http://schemas.microsoft.com/cdo/configuration/
smtpauthenticate") = 1

.Update
End With

'strBody = "This is a sample message." & vbCRLF
'strBody = strBody & "It was sent using CDO." & vbCRLF
strBody = msg & vbCRLF

With objMsg
Set .Configuration = objConf
.To = recipient
.From = "<MY EMAIL>"
.Subject = subject

.HTMLBody = "<br>THIS IS HTMLBODY: " & strBody
.Fields.update

.Send
End With

sendEmail = err.Number

for each field in objMsg.fields
Response.Write("<B>"&field.name&"</B> : " & field.value & "<BR>")
next



Response.Write("======================================<BR>")

End Function

Try adding this to your code:-

objMsg.BodyPart.Charset = "utf-8"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top