{"id":5523,"date":"2019-07-02T19:28:15","date_gmt":"2019-07-02T17:28:15","guid":{"rendered":"https:\/\/www.limilabs.com\/blog\/?p=5523"},"modified":"2019-07-02T19:28:15","modified_gmt":"2019-07-02T17:28:15","slug":"sending-apple-watch-specific-content","status":"publish","type":"post","link":"https:\/\/www.limilabs.com\/blog\/sending-apple-watch-specific-content","title":{"rendered":"Sending Apple Watch specific content"},"content":{"rendered":"<p>There are two main content types used in all HTML emails: text\/plain and text\/html MIME types. <\/p>\n<p>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.<\/p>\n<p>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. <\/p>\n<p>External image is an image that isn\u2019t embedded in the email, using cid: protocol, but loaded from a remote HTTP server using a standard &lt;img src=&#8217;&#8230;&#8217; \/&gt; tag.<\/p>\n<p>You can use <strong>&#8216;text\/watch-html&#8217;<\/strong> type to send a limited HTML version of your message to Apple Watch users, resulting in rich text-like messages on Apple Watch devices.<\/p>\n<p>Here&#8217;s how to create and add such MIME entity using Mail.dll:<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nMailBuilder builder = new MailBuilder();\r\nbuilder.Subject = &quot;Apple Watch Example&quot;;\r\nbuilder.From.Add(new MailBox(&quot;alice@example.com&quot;));\r\nbuilder.To.Add(new MailBox(&quot;bob@example.com&quot;));\r\n\r\nbuilder.Html = &quot;This is &lt;strong&gt;HTML&lt;strong&gt; text.&quot;;\r\nbuilder.Text = &quot;Plain text.&quot;;\r\n\r\nMimeText appleWatchText = new MimeFactory().CreateMimeText();\r\nappleWatchText.ContentType = ContentType.Parse(&quot;text\/watch-html&quot;);\r\nappleWatchText.Text = &quot;This is &lt;strong&gt;Watch HTML&lt;strong&gt; text.&quot;;\r\n\r\nbuilder.Alternatives.Add(appleWatchText);\r\n\r\nIMail mail = builder.Create();\r\n<\/pre>\n<p>Please have in mind that apple watch supports limited version of HTML only.<\/p>\n<p>Using the above code will create an email with following content:<\/p>\n<pre>\r\nContent-Type: multipart\/alternative;\r\n boundary=\"----=_NextPart_19511516.440335455040\"\r\nMIME-Version: 1.0\r\nDate: Tue, 02 Jul 2019 15:38:53 +0200\r\nMessage-ID: &lt;d65fcc07-c988-48e1-a466-166e18998d02@mail.dll&gt;\r\nSubject: Apple Watch Example\r\nFrom: &lt;alice@example.com&gt;\r\nTo: &lt;bob@example.com&gt;\r\n\r\n------=_NextPart_19511516.440335455040\r\nContent-Type: text\/plain;\r\n charset=\"utf-8\"\r\nContent-Transfer-Encoding: 7bit\r\n\r\nPlain text.\r\n------=_NextPart_19511516.440335455040\r\nContent-Type: text\/html;\r\n charset=\"utf-8\"\r\nContent-Transfer-Encoding: 7bit\r\n\r\nThis is &lt;strong&gt;HTML&lt;strong&gt; text.\r\n------=_NextPart_19511516.440335455040\r\nContent-Type: text\/watch-html;\r\n charset=\"utf-8\"\r\nContent-Transfer-Encoding: 7bit\r\n\r\nThis is &lt;strong&gt;Watch HTML&lt;strong&gt; text.\r\n------=_NextPart_19511516.440335455040--\r\n<\/pre>\n<p>Entire sample, including sending process:<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nMailBuilder builder = new MailBuilder();\r\nbuilder.Subject = &quot;Apple Watch Example&quot;;\r\nbuilder.From.Add(new MailBox(&quot;alice@example.com&quot;));\r\nbuilder.To.Add(new MailBox(&quot;bob@example.com&quot;));\r\n\r\nbuilder.Text = &quot;Plain text&quot;;\r\nbuilder.Html = &quot;This is &lt;strong&gt;HTML&lt;strong&gt; text.&quot;;\r\n\r\nMimeText appleWatchText = new MimeFactory().CreateMimeText();\r\nappleWatchText.ContentType = ContentType.Parse(&quot;text\/watch-html&quot;);\r\nappleWatchText.Text = &quot;This is &lt;strong&gt;Watch HTML&lt;strong&gt; text.&quot;;\r\n\r\nbuilder.Alternatives.Add(appleWatchText);\r\n\r\nIMail mail = builder.Create();\r\n\r\n\/\/ Send the message\r\nusing (Smtp smtp = new Smtp())\r\n{\r\n    smtp.Connect(&quot;server.example.com&quot;);   \/\/ or ConnectSSL for SSL\r\n    smtp.UseBestLogin(&quot;user&quot;, &quot;password&quot;); \/\/ remove if not needed\r\n\r\n    smtp.SendMessage(mail);\r\n\r\n    smtp.Close();\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[113],"class_list":["post-5523","post","type-post","status-publish","format-standard","hentry","category-mail-dll","tag-email"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/5523"}],"collection":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/comments?post=5523"}],"version-history":[{"count":19,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/5523\/revisions"}],"predecessor-version":[{"id":5542,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/5523\/revisions\/5542"}],"wp:attachment":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/media?parent=5523"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/categories?post=5523"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/tags?post=5523"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}