为什么这封电子邮件的cc属性在ASP classic中无法正常工作?

时间:2015-06-29 17:44:41

标签: email asp-classic cdonts

当某人分配任务时,也应该通知先前分配该任务的人员。但是,这不起作用。我不确定为什么这封电子邮件没有发送到.Cc电子邮件。有谁知道如何修复此代码? (电子邮件IS发送给msg.to收件人,“testcc”确实返回有效的电子邮件地址值。

Set msg=Server.CreateObject("CDONTS.NewMail")

strSQL = "select emailaddress from UserList where userid = "&assign&";"
Set rs = objConnection.Execute(strSQL, ,adCmdText)

if not(rs.BOF and rs.EOF) then
    temp = rs("emailaddress")
    if(temp<>"" and temp<>"NULL") then
        msg.To = rs("emailaddress")
    end if
end if

strSQL = "select emailaddress from UserList where username = '"&assignedTo&"';"
Set rs = objConnection.Execute(strSQL, ,adCmdText)
if not(rs.BOF and rs.EOF) then
msg.Cc = rs("emailaddress")
testcc = rs("emailaddress")
end if
Response.write(testcc)

msg.From = "support@test.com"
msg.Subject = relname & " TaskID: "&maintid&" - New Task Assignment"
msg.MailFormat = CdoMailFormatMime
msg.BodyFormat = CdoBodyFormatHTML
Enotes = ""
msg.Body = Body & Enotes
msg.Send()

1 个答案:

答案 0 :(得分:2)

首先: CDONTS在Windows 2000中已弃用,在Windows 2003中已完全删除。

我建议使用CDOSYS,可以从Windows 2000到Windows 2008使用。

代码示例:

    On Error Resume Next
        Set myMail = Server.CreateObject("CDO.Message")
        myMail.BodyPart.charset = "unicode-1-1-utf-8"
        myMail.Subject  = EmailSubject
        myMail.HTMLBody = EmailBody
        myMail.From = EmailFrom
        myMail.To = EmailTO
        myMail.Cc = EmailCC
        myMail.BCc = EmailBCC

        myMail.Send
        Result = 2
    If Err.Number <> 0 Then
        Result = -1
    End If

    Set myMail = Nothing