Fog Creek Software
Discussion Board




Email notification using Traditional Chinese

We're using V.3.1.9 on Windows XP, and the Chinese part of the email notifications send out by FogBugz are messed up.

I've traced the code into Function SendEmail in util.asp, and modified several lines to achieve a partial solution.

The original code:
smtp.Message.Text = g_StringUtil.UTF8FromBSTR(sMessage)
msgContentType, "text/plain;charset=UTF-8"

Has been modified to:
smtp.Message.Text = sMessage
smtp.Message.Header.Add msgContentType, "text/plain;charset=big-5"

That fixes the message body of the email.

It seems that there is something wrong in the UTF8 conversion routine, or the assumtion of sMessage being unicode is inaccurate.

Not being a VBScript expert (we're dealing with DVDRW firmware), I still cann't fix the subject line. I suppose converting the subject line into (correct) UTF8 encoding should help, but don't know how.

Liang-Yun wang
Wednesday, March 17, 2004

The subject should be encoded using either BASE64 or QP like the following lines.

=?utf-8?Q?Testing_=C3=88esk=C3=A9?=
=?Big5?B?p9qnabZEp0E=?=

The encoding functionality has been built into DART Mail Tool, which is included with FogBugz installation.

Liang-Yun wang
Wednesday, March 17, 2004

I replaced the SendEmail function with the following one, it it works well for me. I know almost nothing to VBScript, so there must be something left to be improved.

Our email client (Notes 5, Chinese Version) doesn't like long subject lines, so I added some code shorten it.

Function SendEmail( sFrom, sTo, sSubject, sMessage, sError )
    SendEmail = False
    
    On Error Resume Next
    Dim smtp : set smtp = Server.CreateObject("Dart.Smtp")
    smtp.Message.To.Delimiter = ""
    AddAddresses smtp.Message.To, sTo
    
    smtp.Message.From = sFrom
    
  dim t1, t2, t3, t4
  t1 = "123"
  t2 = "123456"
  t3 = "12"
  t1 = sSubject
 
  t4 = CStr(t1)

  Dim msg : set msg = Server.CreateObject("Dart.Message")

  dim i, k
 
  i = Len(t4)


    msg.EncodeBuf CStr(t4), t2, 3
    msg.EncodeBuf CStr(t2), t3, 1
      
  k = len(CStr(t3))
      
    while (k > 72)
      i = i - 3
      t4 = left(t4,i) & "..."
      
      msg.EncodeBuf CStr(t4), t2, 3
      msg.EncodeBuf CStr(t2), t3, 1
      k = len(CStr(t3))
  wend
      
    set msg = nothing
    

    smtp.Message.Subject = "=?utf-8?Q?" & t3 & "?="
    smtp.Message.Text = sMessage
    smtp.Message.Header.Add msgContentType, "text/plain;charset=big-5"
    smtp.Login g_config.sSMTPServer, , g_config.sSMTPUser, g_config.sSMTPPassword
    smtp.Send
    smtp.Logout    
    
    Set smtp = Nothing
    
    If Err.number <> 0 Then
        sError = "Error sending mail to: " & sTo & vbCrLf & Err.Description
        SendEmail = False
        Exit Function
    End If
    On Error Goto 0
    
    SendEmail = True
    
End Function

Liang-Yun wang
Wednesday, March 17, 2004

FB_NOTIFY_RESOLVED in lang.asp cannot have Chinese characters now :(
It seems the encodings among strings are inconsistent.

Liang-Yun Wang
Wednesday, March 17, 2004

The encoding has no bugs in it and works as shipped. I don't recommend anyone make the changes described above. Please email customer support and we'll see what the issue is and help you find a solution in your environment. Thanks.

Dmitri
Fog Creek Software
Thursday, March 18, 2004

Here's how to email tech support:
https://shop.fogcreek.com/PrioritySupport

Dmitri
Fog Creek Software
Thursday, March 18, 2004

*  Recent Topics

*  Fog Creek Home