Embedding Local Images for Email Clients

It is a very common need for developers to use this control to build an Email Message Composer application. We thought about your need and added a very good support in this control for such kind of need. A simple method call will embed all the local images and return .NET MailMessage Object. Just think about it, you do not have to go thru any complicated code writing steps at all. Once you get the MailMessage Object, you can decorate this object with your From Address, To Address, Subject and then, pass this object to your SMTP client. Just simple and clean.

1. Insert a local image from your computer:

Image inserted

2. Send an email message containing embedded images using Content.GetEmailMessageWithLocalImagesEmbedded() method:


private void Button_Click(object sender, RoutedEventArgs e)
    MailMessage mailMessage = wpfHtmlEditor1.Content.GetEmailMessageWithLocalImagesEmbedded();

    mailMessage.To.Add(new MailAddress("toaddress@outlook.com", "Test Man"));
    mailMessage.From = new MailAddress("fromaddress@gmail.com", "Sender Man");

    // if you want to add additional attachmens
    // mail.Attachments.Add(new Attachment("......"));

        SmtpClient mySmtpClient = new SmtpClient("smtp.gmail.com", 587)
            Credentials = new NetworkCredential("fromaddress@gmail.com", "<password>"),
            EnableSsl = true
    catch (Exception err)

Private Sub Button_Click(sender As Object, e As RoutedEventArgs)
	Dim mailMessage As MailMessage = wpfHtmlEditor1.Content.GetEmailMessageWithLocalImagesEmbedded()

	mailMessage.[To].Add(New MailAddress("toaddress@outlook.com", "Test Man"))
	mailMessage.From = New MailAddress("fromaddress@gmail.com", "Sender Man")

	' if you want to add additional attachmens
	' mail.Attachments.Add(new Attachment("......"));

		Dim mySmtpClient As New SmtpClient("smtp.gmail.com", 587) With { _
			Key .Credentials = New NetworkCredential("fromaddress@gmail.com", "<password>"), _
			Key .EnableSsl = True _
	Catch err As Exception
	End Try
End Sub
3. Check your email:

Email received

Last updated on May 29, 2015