Spire.Email 5.2.0 implements LinkedResource interface to add image in message

2022-02-24 07:11:50

We are happy to announce the release of Spire.Email 5.2.0. This version implements LinkedResource interface to add image in message. More details are listed below.

Here is a list of changes made in this release

Category ID Description
New feature SPIREEMAIL-16 Implement LinkedResource interface to add image in message
MailMessage mail = new MailMessage("From@domain.com", "To@domain.com");
// Add TO recipients
mail.To.Add("AddedTo@domain.com");
// Specify ReplyTo 
mail.ReplyTo.Add("ReplyTo@domain.com");
// Add CC recipients
mail.Cc.Add("Cc@domain.com");
// Add BCC recipients
mail.Bcc.Add("Bcc@domain.com");
mail.Subject = "New message created by Spire.Email for .NET";
//How to Reference the resource in html
//example:<body background='cid:ice.png'>
LinkedResource resource = new LinkedResource(@"../../../../../Data/TestData/ice.png");
resource.ContentId = "ice.png";
mail.LinkedResources.Add(resource);
// Set body html
string htmlString = @"
<html>
<body background='cid:ice.png'>
<p> Hello everyone!</p>
<p> Thank you very much for inviting me to the year-end party at your headquarters on Friday, February 10th at 8pm. I would love to attend and look forward to seeing you and your colleagues at the party.</p>
<p> I wish the company's annual meeting a complete success.<br>Nina<br>January 12, 2022 </p>
</body>
</html>";
mail.BodyHtml = htmlString;
// Save message
mail.Save("CreateNewEmail.msg", MailMessageFormat.Msg);
Click the link to download Spire.Email 5.2.0: