无法向所有收件人发送邮件

时间:2014-03-03 16:22:02

标签: vb.net email system.net.mail

我正在尝试使用Net.Mail发送邮件。

我在第

行中收到的错误消息
"nClient.Send(nMail)"

是:

"Could not send mail to all recipients." 

我不知道我做错了什么。

有人看到我的错误吗?

非常感谢!

        Dim sSubject As String = "Response to your order"
        Dim sBody As String = "Dear Sir or Madame, here is your invoice."

        Dim sTo As String = "customer@customers.com"
        Dim sFrom As String = "office@mycompany.com"
        Dim sFromFriendly As String = "My super nice office team"

        Dim nAtt As Net.Mail.Attachment = New Net.Mail.Attachment("C:\somepdf.pdf")

        Dim nMail As New Net.Mail.MailMessage(sFrom, sTo, sSubject, sBody)
        With nMail
            .IsBodyHtml = False
            .Bcc.Add(sFrom) 'Send a BCC to myself
            .From = New MailAddress(sFrom, sFromFriendly) 'Add my nice name moniker
            .Attachments.Add(nAtt) 'Add the pdf file
        End With

        Dim nCred As New System.Net.NetworkCredential
        With nCred
            .UserName = "myusername"
            .Password = "mypassword"
        End With

        Dim nClient As New SmtpClient()
        With nClient
            .Host = "mywebhost"
            .Port = 587
            .UseDefaultCredentials = False
            .Credentials = nCred
        End With

        nClient.Send(nMail)

        nMail.Dispose()

0 个答案:

没有答案