Vb.net 无法向所有收件人发送邮件
我正在尝试使用Net.mail发送邮件 我在队列中得到的错误消息Vb.net 无法向所有收件人发送邮件,vb.net,email,system.net.mail,Vb.net,Email,System.net.mail,我正在尝试使用Net.mail发送邮件 我在队列中得到的错误消息 "nClient.Send(nMail)" 是: 我不知道我哪里做错了什么 有人看到我的错误了吗 多谢各位 Dim sSubject As String = "Response to your order" Dim sBody As String = "Dear Sir or Madame, here is your invoice." Dim sTo As String = "
"nClient.Send(nMail)"
是:
我不知道我哪里做错了什么
有人看到我的错误了吗
多谢各位
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()
您的代码似乎是正确的。错误通常有一个错误代码,该代码提供了有关出错原因的更多信息。可能此错误代码在InnerExceptionTanks中,将进行检查。此错误是由我的Web主机引发的,因为密件抄送地址不存在。
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()