tried this with VS 2017 , it works fine but it can not send the attachment it throws an Exception Error every time it is trying to attach the file ..
@AnkproTraining4 жыл бұрын
We have used outlook.com email, are you trying with same or gmail?
@vijaysahuhrd6 жыл бұрын
Tried but getting this : A connection attempt failed because the connected party did not properly respond after a period of time
@AnkproTraining6 жыл бұрын
Are you using office network or office laptop? They might have blocked the port.
@vijaysahuhrd6 жыл бұрын
Thanks for your quick response : Actually I am using my personal laptop with my home wifi connection
@AnkproTraining6 жыл бұрын
Are you using gmail or outlook.com? verify the port number and smtp url one more time. If everything ok paste your code except password. We will check from here
@vijaysahuhrd6 жыл бұрын
Using port 587 and smtp.gmail.com for gmail account... I have also tried with 25 port
@AnkproTraining6 жыл бұрын
var client = new SmtpClient("smtp.gmail.com", 587) { Credentials = new NetworkCredential("myusername@gmail.com", "mypwd"), EnableSsl = true }; client.Send("myusername@gmail.com", "myusername@gmail.com", "test", "testbody"); Console.WriteLine("Sent"); Console.ReadLine(); You may also need to enable access for "less secure apps" in your gmail settings page: google.com/settings/security/lesssecureapps. This is necessary if you are getting the exception "`The server response was: 5.5.1 Authentication Required. If you don't get the success, paste your code here and remove the password in code.