0

据了解,如果端口号不是 25,则 smtp 邮件任务不起作用。所以从链接中找到了一些脚本来完成工作

http://englestone.blogspot.co.uk/2008/05/ssis-send-mail-task-change-smtp-port.html

根据我的需要进行修改时,它显示“SMTP 服务器需要安全连接或客户端未通过身份验证”

问题是如何在这个 vb 代码上添加安全连接部分,或者这个错误是由于身份验证导致的,那么与身份验证对应的代码是正确的?

请找到脚本

Public Sub Main()
        Dim myHtmlMessage As MailMessage
        Dim mySmtpClient As SmtpClient



        myHtmlMessage = New MailMessage("sender@s.com", "receiver@s.com", "subject", "body")
        mySmtpClient = New SmtpClient("send.company.net")
        mySmtpClient.Port = 587
        mySmtpClient.Credentials = CredentialCache.DefaultNetworkCredentials("sender@s.net", "sender email pwd")




        mySmtpClient.Send(myHtmlMessage)
     Dts.TaskResult = ScriptResults.Success
    End Sub

任何vb.net/smtp/专家请回复

4

1 回答 1

1

You need to configure your SmtpClient to use ssl like:

mySmtpClient.EnableSsl = true

this should do the trick.

EDIT: To use the correct credentials use:

mySmtpClient.Credentials = new System.Net.NetworkCredential("yourusername", "yourpassword")
于 2013-08-08T11:25:16.653 回答