Problem with the encoding of a CDO subject
am 30.12.2007 20:30:40 von 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("
")
Response.Write(subject)
Response.Write("
")
Response.Write(msg)
Response.Write("
")
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/sendus ing") =
cdoSendUsingPort
.Item("http://schemas.microsoft.com/cdo/configuration/smtpse rver") =
"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/smtpus essl") =
True
.Item("http://schemas.microsoft.com/cdo/configuration/sendus ername")
= ""
.Item("http://schemas.microsoft.com/cdo/configuration/sendpa ssword")
=""
.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 = ""
.Subject = subject
.HTMLBody = "
THIS IS HTMLBODY: " & strBody
.Fields.update
.Send
End With
sendEmail = err.Number
for each field in objMsg.fields
Response.Write(""&field.name&" : " & field.value & "
")
next
Response.Write("======================================
")
End Function
Re: Problem with the encoding of a CDO subject
am 30.12.2007 23:29:31 von Anthony Jones
"ioannisd" wrote in message
news:c2502d4b-b5c4-4b12-bcce-0ce941913624@w47g2000hsa.google groups.com...
> 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("
")
> Response.Write(subject)
> Response.Write("
")
> Response.Write(msg)
> Response.Write("
")
>
>
>
> 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/sendus ing") =
> cdoSendUsingPort
> .Item("http://schemas.microsoft.com/cdo/configuration/smtpse rver") =
> "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/smtpus essl") =
> True
> .Item("http://schemas.microsoft.com/cdo/configuration/sendus ername")
> = ""
> .Item("http://schemas.microsoft.com/cdo/configuration/sendpa ssword")
> =""
> .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 = ""
> .Subject = subject
>
> .HTMLBody = "
THIS IS HTMLBODY: " & strBody
> .Fields.update
>
> .Send
> End With
>
> sendEmail = err.Number
>
> for each field in objMsg.fields
> Response.Write(""&field.name&" : " & field.value & "
")
> next
>
>
>
> Response.Write("======================================
")
>
> End Function
>
Try adding this to your code:-
objMsg.BodyPart.Charset = "utf-8"
--
Anthony Jones - MVP ASP/ASP.NET
Re: Problem with the encoding of a CDO subject
am 31.12.2007 07:46:28 von ioannisd
On Dec 31, 12:29 am, "Anthony Jones" wrote:
> "ioannisd" wrote in message
>
> news:c2502d4b-b5c4-4b12-bcce-0ce941913624@w47g2000hsa.google groups.com...
>
>
>
> > 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("
")
> > Response.Write(subject)
> > Response.Write("
")
> > Response.Write(msg)
> > Response.Write("
")
>
> > 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/sendus ing") =
> > cdoSendUsingPort
> > .Item("http://schemas.microsoft.com/cdo/configuration/smtpse rver") =
> > "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/smtpus essl") =
> > True
> > .Item("http://schemas.microsoft.com/cdo/configuration/sendus ername")
> > = ""
> > .Item("http://schemas.microsoft.com/cdo/configuration/sendpa ssword")
> > =""
> > .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 = ""
> > .Subject = subject
>
> > .HTMLBody = "
THIS IS HTMLBODY: " & strBody
> > .Fields.update
>
> > .Send
> > End With
>
> > sendEmail = err.Number
>
> > for each field in objMsg.fields
> > Response.Write(""&field.name&" : " & field.value & "
")
> > next
>
> > Response.Write("======================================
")
>
> > End Function
>
> Try adding this to your code:-
>
> objMsg.BodyPart.Charset = "utf-8"
>
> --
> Anthony Jones - MVP ASP/ASP.NET
Fixed!
Thanks