2
To send an email from the application I am using the MailMessage
available. I am now trying to place an image in the email body via html:
MailMessage mail = new MailMessage();
SmtpClient SmtpCliente = new SmtpClient(server);
...
mail.IsBodyHtml = true;
mail.Body += "<br />Cumprimentos,<br />";
mail.Body += "<img src=\"D://MediaOleotorres/logoOleotorresAssinatura.png\" height=\"42\" width=\"42\">";
However when sending the email, the image does not appear. I have to use an image that is available online?
EDIT: I have also tried to put the image as attached and then add it to the body, it is possible?
string attachmentPath = @"D:/MediaOleotorres/imagens/logoOleotorresAssinatura.png";
Attachment inline = new Attachment(attachmentPath);
inline.ContentDisposition.Inline = true;
inline.ContentDisposition.DispositionType = DispositionTypeNames.Inline;
inline.ContentType.MediaType = "image/png";
inline.ContentType.Name = Path.GetFileName(attachmentPath);
mail.Attachments.Add(inline);
You can accept your own answer in this case.
– Maniero