@Jair Onofre , as others said, there is no need to encode it in Base64 If you want to send email with embedded image by using c#.
Here is a code example you could refer to.
static void Main(string[] args)
{
SendMessageWithEmbeddedImages();
}
public static void SendMessageWithEmbeddedImages()
{
string htmlMessage = @"<html>
<body>
<img src='cid:EmbeddedContent_1' />
</body>
</html>";
SmtpClient client = new SmtpClient("smtp.gmail.com");
client.Port = 587;
client.Credentials = new NetworkCredential("******@gmail.com", "Password");
client.EnableSsl = true;
MailMessage msg = new MailMessage("******@gmail.com",
"******@hotmail.com");
// Create the HTML view
AlternateView htmlView = AlternateView.CreateAlternateViewFromString(
htmlMessage,
Encoding.UTF8,
MediaTypeNames.Text.Html);
// Create a plain text message for client that don't support HTML
string mediaType = MediaTypeNames.Image.Jpeg;
LinkedResource img = new LinkedResource(@"D:\2.jpg", mediaType);
// Make sure you set all these values!!!
img.ContentId = "EmbeddedContent_1";
img.ContentType.MediaType = mediaType;
img.TransferEncoding = TransferEncoding.Base64;
img.ContentType.Name = img.ContentId;
img.ContentLink = new Uri("cid:" + img.ContentId);
htmlView.LinkedResources.Add(img);
msg.AlternateViews.Add(htmlView);
msg.IsBodyHtml = true;
msg.Subject = "Some subject";
client.Send(msg);
}
Based on my test, the above method can send the email with embedded image successfully.
Please note that we need to enable Less secure app access in the link: Enable Less secure app.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.