I want to send email with image the image is the header of the email body how i attach the image to my body of the email the image is save in my pc local folder / project folder my code is
using(var client = new SmtpClient())
{
foreach(FeeEntry student in q)
{
client.Connect("smtp.gmail.com", 465);
client.Authenticate("emailaddress", "password");
var bodyBuilder = new BodyBuilder
{
HtmlBody = $ "<img src='** i want to add image here **'/>" +
$ "<h3 style = 'border:2px solid blue; margin-right: 123px ;text-align: center'>Remaing Fee Notification from(OCMWP) </h3>" +
$ "<table style = 'border:2px solid blue' border='1'> <thead> </thead> <tr>" +
$ "<th> </th><th>Name</th> <th>Fee Type </th> <th>Fee Amount</th> </tr> " +
$ "<tbody> <tr> <th>1</th> <td>{student.students.StdName}</td> <td> {student.AddFeeInfo.Feetype} </td> <td> {student.AddFeeInfo.FeeAmount} </td><tr> </tbody> </table> ",
TextBody = "{formData.ID}\r\n{ formData.subject}\r\n{formData.body}\r\n{formData.Email}"
};
var message = new MimeMessage
{
Body = bodyBuilder.ToMessageBody()
};
message.From.Add(new MailboxAddress("No Reply OCMWP", "bs180201421@vu.edu.pk"));
message.To.Add(new MailboxAddress(student.students.StdName, student.students.StdEmailAddress));
message.Subject = "Panding ( OCMWP)";
client.Send(message);
client.Disconnect(true);
}
}
i also try this code but not working please you have another way please guide me
foreach(var attachment in attachments)
{
mailMessage.Attachments.Add(new Attachment(attachment));
}