Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am having problem to get this section to work its get a strange error when i try to run the debug "
Error while trying to run project. Unable to start program c:users\.......\debug\windowsapp2.exe

Any help would be great

What I have tried:

VB.NET
Imports System.Net.Mail


Dim smtpserver As New SmtpClient
            smtpserver.EnableSsl = True
            Dim mail As New MailMessage
            smtpserver.Credentials = New Net.NetworkCredential("my emailaddress", "password")
            smtpserver.Port = 587
            smtpserver.Host = "smtp.gmail.com"
            mail = New MailMessage
            mail.From = New MailAddress("my email address.com")
            mail.To.Add("email address.co.uk")
            mail.Subject = "testing auto mail"
            mail.Body = "just test of new mail"
            smtpserver.Send(mail)
Posted
Updated 18-Apr-20 11:24am
v2
Comments
F-ES Sitecore 18-Apr-20 12:35pm    
If you remove that code does your exe start?
Maciej Los 18-Apr-20 17:13pm    
5ed!
Member 14805048 19-Apr-20 7:07am    
yes, i have no problem if i remove that code
Richard Deeming 21-Apr-20 12:04pm    
Is that the entire contents of your code file? That code needs to be in a method, which should be in a class or a module.

1 solution

Check this: c# - Sending email in .NET through Gmail - Stack Overflow[^]

You need to set up also:
VB.NET
With smtpserver
   '...
   .EnableSsl = True
   .DeliveryMethod = SmtpDeliveryMethod.Network
   .UseDefaultCredentials = False
   '...
End With
 
Share this answer
 
Comments
Member 14805048 19-Apr-20 7:14am    
added this to the code and it still failed

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