Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Other Development Tools
 UNICODE CDOSYS email

Author  Topic 

SamC
White Water Yakist

3467 Posts

Posted - 2005-02-08 : 10:59:01
We need to migrate our SQL database to Windows 2003 server. Support for CDONTS has been replace by CDOSYS. I've put some effort into recoding a subroutine from CDONTS to CDOSYS and am stuck on two points.

- I can't get the subject like to display UNICODE, although the iMessage component claims it can be done, I haven't got UNICODE to render properly at all.

- We need to "display" the user's From address while using our address as the actual From address. This avoids problems on some of our client's spam filters. Coding the actual from and display from are usually done something like this:

.From = "<ouraddress@ourdomain.com>" & sFromAddress

Where the bracketed email is the from and anything else is the displayed name.

but this is consistently displayed as:

John+AEA-mydomain.com instead of John@mydomain.com (assuming sFromAddress = "John@mydomain.com"

Here is the code that sends UNICODE text and supports Read Receipt and Importance.

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

Sub SendMail (sFromAddress, sToAddress, sCcAddress, sBccAddress, sSubject, sBody, boolReadReceipt, intImportance )
' on error resume next
Const cdoDispositionNotificationTo = "urn:schemas:mailheader:disposition-notification-to"
Const cdoReturnReceiptTo = "urn:schemas:mailheader:return-receipt-to"
dim cdoMessage

Set cdoMessage = CreateObject("CDO.Message")
With cdoMessage

.BodyPart.charset = "unicode-1-1-utf-7"

IF boolReadReceipt Then
.Fields(cdoDispositionNotificationTo) = sFromAddress
.Fields(cdoReturnReceiptTo) = sFromAddress
End If

' Set the Importance: 0:Low, 1:Normal, 2:High
.Fields("urn:schemas:httpmail:importance").Value = intImportance
.Fields.Update
.From = "<myprefix@anotherdomain.com>" & sFromAddress
.ReplyTo = sFromAddress
.To = sToAddress
.Cc = sCcAddress
.Bcc = sBccAddress
.Subject = sSubject
.textbody = sBody
.Send
End With

Set cdoMessage = Nothing
Set cdoConfig = Nothing
End Sub

Call SendMail("myfrom@mydomain.com", "myto@mydomain.com", _
"", "", "Test2 Subject - Read Receipt", _
"Japanese: #26085;#26412;#12398;#20445;#35388;#24847;#35672;", true, 2 )
%>


Any thoughts that might assist in solving either of these two problems?

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-02-08 : 11:04:56
have you tried it without codepage part in <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
and using uft-8 instead of utf-7?

Go with the flow & have fun! Else fight the flow
Go to Top of Page

SamC
White Water Yakist

3467 Posts

Posted - 2005-02-08 : 11:19:52
quote:
Originally posted by spirit1

have you tried it without codepage part in <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
and using uft-8 instead of utf-7?

I've struggled with insufficent docuementation on Microsoft's website regarding these points. Here's what I have...

The CODEPAGE I'm pretty confident about. It's gotta be a number, and it seems to define the way string variables are handled in ASP. Since the body text of the email is rendering Japanese fine, I doubt the problems with the Subject are due to CODEPAGE.


65001 is a UTF-8 codepage. Here's Microsoft's page on CODEPAGE.

Then there's

.BodyPart.charset = "unicode-1-1-utf-7"

Documentation on character set identities can be found here .

So, I've changed this:

.BodyPart.charset = "unicode-1-1-utf-8"

Strangely, this fixes the "From" address coding of the "at" (@) symbol, but the Subject line still isn't displaying Japanese. I'll try the iMessage component again using this charset and post back here later.

Thanks,

Sam
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-02-08 : 11:31:08
well i had a similar problem that solved by itself when i put
Response.Charset = "SomeCharset"
and
Response.Write("<meta charset=""your charset"" />")

mine wouldn't display correct chars in the body of the mail.



Go with the flow & have fun! Else fight the flow
Go to Top of Page

SamC
White Water Yakist

3467 Posts

Posted - 2005-02-08 : 11:39:14
quote:
Originally posted by spirit1

well i had a similar problem that solved by itself when i put
Response.Charset = "SomeCharset"
and
Response.Write("<meta charset=""your charset"" />")

mine wouldn't display correct chars in the body of the mail.


Well, that's surprising, since the email is not a part of the rendered page, but who knows...

Does anyone know a usergroup forum that addresses at problems like this?
Go to Top of Page

SamC
White Water Yakist

3467 Posts

Posted - 2005-02-08 : 14:01:14
Last bug squashed. The Subject is being encoded with UNICODE properly. Outlook doesn't display it, but the Thunderbird email software from Mozilla will.

I posted the code for posterity.
Go to Top of Page
   

- Advertisement -