发送邮件时出错:smtpexception发送邮件失败

编程入门 行业动态 更新时间:2024-10-19 11:55:17
本文介绍了发送邮件时出错:smtpexception发送邮件失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个Windows应用程序表单,用于向多个电子邮件发送电子邮件通知。我会通知员工,他们的帐户已经记入了索赔。我收到错误发送邮件失败

I have a windows application form for sending email notification to multiple email. I will notify employees that claims is already credited in their account. I got an error "failure sending mail"

SMTP.Send(Email)

'错误在这个 我尝试过: 这是我的代码

'error on this What I have tried: Here's my code

Private Sub SendMail(ByVal vEmail As String, ByVal vName As String, ByVal vDetail As String) Dim Txt As String Dim tmp1 As String Dim tmp As String Dim client As New Net.Mail.SmtpClient() Mailer = New Net.Mail.MailMessage With Mailer 'Dim SendRes As String Dim SMTP As New Net.Mail.SmtpClient("************") Dim Email As New Net.Mail.MailMessage() SMTP.Port = 25 SMTP.UseDefaultCredentials = False SMTP.Credentials = New Net.NetworkCredential("******", "*******") SMTP.EnableSsl = True Email = New Net.Mail.MailMessage() 'From Email.From = New Net.Mail.MailAddress("************") Txt = "" If vEmail = "none" Then vEmail = GetSenderEmail() Txt = vbCrLf Txt = Txt & vbCrLf Txt = Txt & "NOTE:" Txt = Txt & vbCrLf Txt = Txt & "Please update email address." Txt = Txt & vbCrLf Txt = Txt & "*** Please add the email address of " & vName & " in your vendors profile." Else Email.CC.Add("*********") 'GetSenderEmail() End If 'To Email.To.Add("*********") 'Subject Email.Subject = "Payroll Account Credit (Please Do Not Reply)" 'BODY tmp1 = "Your payroll account was/will be credited on " & DTdateCredit.Value & "" & vbNewLine tmp = tmp1 & vbNewLine tmp = tmp1 & "***Below are the details:" & vbNewLine tmp = tmp1 & vbNewLine tmp = tmp1 & vDetail tmp = tmp1 & tmp & Txt Email.Body = tmp Email.IsBodyHtml = False SMTP.Send(Email) MsgBox("Sent Successfully") Email.Dispose() End With Mailer = Nothing End Sub

推荐答案

如果没有有意义的错误消息,这是无法解决的。 为了得到它,请尝试将代码包含在内阻止并报告捕获的异常: This can't be solved without having a meaningful error message. To get that enclose your code with a try block and report catched exceptions: Try ' Email sending code here Catch ex As Exception MsgBox(ex.ToString) End Try

该邮件应包含SMTP错误代码和文本,告诉您邮件无法发送的原因l ike无效凭据,无法中继,未知收件人,邮箱已满。

The message should then contain the SMTP error code and text telling you why the mail couldn't be send like invalid credentials, unable to relay, unknown recipient, mailbox full.

更多推荐

发送邮件时出错:smtpexception发送邮件失败

本文发布于:2023-11-17 12:18:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1609980.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:发送邮件   smtpexception

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!