Sending Apple Watch specific content

There are two main content types used in all HTML emails: text/plain and text/html MIME types.

You should always include a plain text version of your email that closely matches to the HTML version of your email. Mail.dll will generate (extract) plain text automatically, if you provide HTML text only.

Usually Apple watch displays only the plain text part of your email. In most cases it considers the HTML too complicated (e.g. external images are referenced), so it shows the plain text version instead.

External image is an image that isn’t embedded in the email, using cid: protocol, but loaded from a remote HTTP server using a standard <img src=’…’ /> tag.

You can use ‘text/watch-html’ type to send a limited HTML version of your message to Apple Watch users, resulting in rich text-like messages on Apple Watch devices.

Here’s how to create and add such MIME entity using Mail.dll:

MailBuilder builder = new MailBuilder();
builder.Subject = "Apple Watch Example";
builder.From.Add(new MailBox("alice@example.com"));
builder.To.Add(new MailBox("bob@example.com"));

builder.Html = "This is <strong>HTML<strong> text.";
builder.Text = "Plain text.";

MimeText appleWatchText = new MimeFactory().CreateMimeText();
appleWatchText.ContentType = ContentType.Parse("text/watch-html");
appleWatchText.Text = "This is <strong>Watch HTML<strong> text.";

builder.Alternatives.Add(appleWatchText);

IMail mail = builder.Create();

Please have in mind that apple watch supports limited version of HTML only.

Using the above code will create an email with following content:

Content-Type: multipart/alternative;
 boundary="----=_NextPart_19511516.440335455040"
MIME-Version: 1.0
Date: Tue, 02 Jul 2019 15:38:53 +0200
Message-ID: <d65fcc07-c988-48e1-a466-166e18998d02@mail.dll>
Subject: Apple Watch Example
From: <alice@example.com>
To: <bob@example.com>

------=_NextPart_19511516.440335455040
Content-Type: text/plain;
 charset="utf-8"
Content-Transfer-Encoding: 7bit

Plain text.
------=_NextPart_19511516.440335455040
Content-Type: text/html;
 charset="utf-8"
Content-Transfer-Encoding: 7bit

This is <strong>HTML<strong> text.
------=_NextPart_19511516.440335455040
Content-Type: text/watch-html;
 charset="utf-8"
Content-Transfer-Encoding: 7bit

This is <strong>Watch HTML<strong> text.
------=_NextPart_19511516.440335455040--

Entire sample, including sending process:

MailBuilder builder = new MailBuilder();
builder.Subject = "Apple Watch Example";
builder.From.Add(new MailBox("alice@example.com"));
builder.To.Add(new MailBox("bob@example.com"));

builder.Text = "Plain text";
builder.Html = "This is <strong>HTML<strong> text.";

MimeText appleWatchText = new MimeFactory().CreateMimeText();
appleWatchText.ContentType = ContentType.Parse("text/watch-html");
appleWatchText.Text = "This is <strong>Watch HTML<strong> text.";

builder.Alternatives.Add(appleWatchText);

IMail mail = builder.Create();

// Send the message
using (Smtp smtp = new Smtp())
{
    smtp.Connect("server.example.com");   // or ConnectSSL for SSL
    smtp.UseBestLogin("user", "password"); // remove if not needed

    smtp.SendMessage(mail);

    smtp.Close();
}

Tags:

Questions?

Consider using our Q&A forum for asking questions.