0

当任务分配给某人时,该任务之前分配给的人也应该得到通知。但是,这是行不通的。我不确定为什么这封电子邮件没有发送到 .Cc 电子邮件。有谁知道如何修复此代码?(电子邮件正在发送给 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()
4

1 回答 1

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
于 2015-06-30T07:42:18.263 回答