Sending mail with an embedded image in ASP.NET

I want to send mail with an embedded image in ASP.NET

How can i do this?

Relationship Soner

+3
source share
4 answers

There are usually two ways to do this, depending on what suits you best.

To literally "embed" an image in an email message, you need to add it as a Linked Resource and link to the attached resource in an HTML email message.

Alternatively, and, more simply put, if the image is located in a public location, you can simply link to that location in an HTML email.

, , , .

+9
MailAddress sendFrom = new MailAddress(txtFrom.Text);
MailAddress sendTo = new MailAddress(txtTo.Text);

MailMessage myMessage = new MailMessage(sendFrom, sendTo);

MyMessage.Subject = txtSubject.Text;
MyMessage.Body = txtBody.Text;

Attachment attachFile = new Attachment(txtAttachmentPath.Text);
MyMessage.Attachments.Add(attachFile);

SmtpClient emailClient = new SmtpClient(txtSMTPServer.Text);
emailClient.Send(myMessage);
+1

, , , , HTML, Base64.

+1

http://www.dotnetspider.com/resources/41465-Send-Formatted-outlook-email-from-NET-C.aspx

An example project is also included.

It shows how to put an image link in an application in an html template and send emails.

+1
source

Source: https://habr.com/ru/post/1782786/


All Articles