ruben00000 says:
LinkedResource header =
new
LinkedResource(
"D:\\Project\\Email\\Email\\Email\\Header.jpeg"
, MediaTypeNames.Image.Jpeg);
header.ContentId =
"Header"
;
LinkedResource footer =
new
LinkedResource(
"D:\\Project\\Email\\Email\\Email\\Header.jpeg"
, MediaTypeNames.Image.Jpeg);
header.ContentId =
"Footer"
;
You are setting ContentId Header and Footer for LinkedResource header not for footer.
Check with below code.
string body = "test email";
string htmlBody = string.Format("<html><body height: 100%>" +
"<img src=\"cid:Header\" width='1000px' /><br />{0}<br />" +
"<img src=\"cid:Footer\" width='1000px' />" +
"</body>" +
"</html>", body);
AlternateView avHtml = AlternateView.CreateAlternateViewFromString(htmlBody, Encoding.Default, MediaTypeNames.Text.Html);
LinkedResource header = new LinkedResource(@"C:\Users\developer4\Desktop\Daily_Process.png", MediaTypeNames.Image.Jpeg);
header.ContentId = "Header";
avHtml.LinkedResources.Add(header);
LinkedResource footer = new LinkedResource(@"C:\Users\developer4\Desktop\154884.jpg", MediaTypeNames.Image.Jpeg);
footer.ContentId = "Footer";
avHtml.LinkedResources.Add(footer);
MailMessage mail = new MailMessage("sender@gmail.com", "receiver@gmail.com");
mail.Subject = "Subject";
mail.IsBodyHtml = true;
mail.AlternateViews.Add(avHtml);
SmtpClient client = new SmtpClient
{
EnableSsl = true,
Credentials = new NetworkCredential("sender@gmail.com", "password"),
Host = "smtp.gmail.com",
Port = 587
};
client.Send(mail);