none
VB引用CDO组件发送TLS邮件失败 RRS feed

  • 问题

  • 现在用VB6.0开发一个发送邮件程序,引用Windows系统下的cdosys.dll编写代码发送邮件,使用无加密或者SSL加密类型的邮件发送服务器进行发送没问题,但是使用TLS加密的邮件发送服务器进行发送却始终提示不成功(错误号为:  '-2147220973)。是否系统的cdosys.dll组件不支持发送TLS加密类型的邮件?请问windows下还有其他组件可以支持发送TLS加密类型的邮件吗?请各位高手帮忙解答,盼复,谢谢!

    附上测试代码:

    Private Sub cmdTest_Click()
        Dim i                       As Long
        Dim oMsg                    As Object
        Dim oConf                   As Object
        Dim oFlds                   As Object

        On Error GoTo hError:
        Set oMsg = CreateObject("CDO.Message")
        Set oConf = CreateObject("CDO.Configuration")
       
        Set oFlds = oConf.Fields
        oFlds(cdoSMTPServer) = "smtp.gmail.com"                                   
        oFlds(cdoSendUsingMethod) = cdoSendUsingPort
        oFlds(cdoSMTPServerPort) = 587
        oFlds(cdoSMTPUseSSL) = 1
        oFlds(cdoSMTPAuthenticate) = cdoBasic
        oFlds(cdoSendUserName) = "testuser"
        oFlds(cdoSendPassword) = "test"
        oFlds.Update

        With oMsg
            Set .Configuration = oConf
            .BodyPart.Charset = "GB2312"
            .BodyPart.ContentTransferEncoding = "base64"
            .MimeFormatted = False
            .AutoGenerateTextBody = True
            .From = txtFromEmailAddress.Text'发件人邮箱
            .Subject = "测试邮箱"
            .HTMLBody = "测试发送邮件成功!"
            .To = txtToEmailAddress.Text'收件人邮箱
            .Send
        End With
        MsgBox "测试发送邮件成功"
        Set oMsg = Nothing
        Set oConf = Nothing
        Exit Sub
    hError:
        Set oMsg = Nothing
        Set oConf = Nothing
        Err.Raise Err.Number, Err.Source, Err.Description
    End Sub

    2012年12月21日 3:15