I am trying to send email with attached pdf, my pdf is in byte array. and when i try to send mail (without pdf) it shows
Message = The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at
my code is `string senderEmail = System.Configuration.ConfigurationManager.AppSettings["SenderEmail"].ToString(); string senderPassword = System.Configuration.ConfigurationManager.AppSettings["SenderPassword"].ToString();
SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
client.EnableSsl = true;
client.Timeout = 100000;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Credentials = new NetworkCredential(senderEmail, senderPassword);
MailMessage mailMassege = new MailMessage(senderEmail, toEmail, subject, body);
mailMassege.IsBodyHtml = true;
mailMassege.BodyEncoding = Encoding.UTF8;
client.Send(mailMassege);`
and my pdf is in byte array
byte[] applicationPDFData = actionResult.BuildPdf(ControllerContext);
System.IO.File.WriteAllBytes(filePath + "/hello.pdf", applicationPDFData);
I want to to send mail with this pdf. thanks in advance