My code as follows
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
mail.From = new MailAddress("[email protected]");
mail.To.Add("[email protected]");
mail.Subject = "Test Mail - 1";
mail.Body = "mail with attachment";
System.Net.Mail.Attachment attachment;
attachment = new System.Net.Mail.Attachment(@"C:\Users\551386\Desktop\DataDump\Excel.xls");
mail.Attachments.Add(attachment);
SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential("raj@gmailcom","12345");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
Code
when i execute the above code shows error as followsCode
Failure sending mailCode
the above error shows in below line as followsCode
SmtpServer.Send(mail);
Tapan PatelRank #614 · 3.9K reputationPosted Aug 25, 2016, 6:16 AM EDT