mail is going well with the first attachment but cannot carry the second attachment.
Here is my code,
public Boolean SendMail_EmbededImage(string mail, string mailSubject, string MailBody, bool p, string fileName)
{
string SmtpClient = ConfigurationManager.AppSettings["SmtpClient"].ToString();
string MailFrom = ConfigurationManager.AppSettings["MailFrom"].ToString();
string NetCredUserName = ConfigurationManager.AppSettings["NetCredUserName"].ToString();
string NetCredPassword = ConfigurationManager.AppSettings["NetCredPassword"].ToString();
string PdfPath = ConfigurationManager.AppSettings["CopyOfPDF"].ToString();
int SMTPPort = Convert.ToInt32(ConfigurationManager.AppSettings["SMTPPort"].ToString());
try
{
MailMessage mail1 = new MailMessage();
SmtpClient SmtpServer = new SmtpClient(SmtpClient);
mail1.From = new MailAddress(MailFrom);
mail1.To.Add(mail);
mail1.Subject = mailSubject;
mail1.IsBodyHtml = true;
mail1.Attachments.Add(new Attachment(fileName));
if (File.Exists("Annex_" + fileName))
mail1.Attachments.Add(new Attachment("Annex_" + fileName));
mail1.Body = MailBody;
SmtpServer.Port = SMTPPort;
SmtpServer.Credentials = new System.Net.NetworkCredential(NetCredUserName, NetCredPassword);
//SmtpServer.EnableSsl = true;
ServicePointManager.ServerCertificateValidationCallback = delegate (object s,
System.Security.Cryptography.X509Certificates.X509Certificate certificate,
System.Security.Cryptography.X509Certificates.X509Chain chain,
SslPolicyErrors sslPolicyErrors)
{
return true;
};
SmtpServer.Send(mail1);
p = true;
}
catch (Exception ex)
{
p = false;
}
return p;
}