{"id":1155,"date":"2010-09-23T17:45:07","date_gmt":"2010-09-23T15:45:07","guid":{"rendered":"http:\/\/www.limilabs.com\/blog\/?p=1155"},"modified":"2019-03-15T17:00:47","modified_gmt":"2019-03-15T15:00:47","slug":"high-priority-emails","status":"publish","type":"post","link":"https:\/\/www.limilabs.com\/blog\/high-priority-emails","title":{"rendered":"High priority emails"},"content":{"rendered":"<p>There are several different email headers that make email <strong>high priority<\/strong>.<\/p>\n<p>Most correct is <em>Priority<\/em> header, but also <em>Importance <\/em>is used.<br \/>\nOutlook uses <em>X-Priority<\/em> header.<\/p>\n<p><a href=\"\/mail\">Mail.dll email library<\/a> offers simple solution of this problem: <strong>PriorityHigh()<\/strong> method.<\/p>\n<p>The following code sends high priority email, that has all mentioned above headers set accordingly:<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\/\/ C# version:\r\nMailBuilder builder = new MailBuilder();\r\nbuilder.Subject = &quot;This is important&quot;;\r\nbuilder.Html = &quot;&lt;html&gt;....&lt;\/html&gt;&quot;;\r\nbuilder.From.Add(new MailBox(&quot;alice@mail.com&quot;, &quot;Alice&quot;));\r\nbuilder.To.Add(new MailBox(&quot;bob@mail.com&quot;, &quot;Bob&quot;));\r\n\r\nbuilder.PriorityHigh();\r\n\r\nIMail email = builder.Create();\r\n\r\nusing (Smtp client = new Smtp())\r\n{\r\n    client.ConnectSSL(&quot;smtp.example.org&quot;);\r\n    client.UseBestLogin(&quot;alice@example.org&quot;, &quot;password&quot;);\r\n    client.SendMessage(email);\r\n    client.Close();\r\n}\r\n\r\n<\/pre>\n<p>and as usual VB.NET code:<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\n' VB.NET version:\r\n\r\nDim builder As MailBuilder = New MailBuilder()\r\nbuilder.Subject = &quot;This is important&quot;\r\nbuilder.Html = &quot;&lt;html&gt;....&lt;\/html&gt;&quot;\r\nbuilder.From.Add(New MailBox(&quot;alice@mail.com&quot;, &quot;Alice&quot;))\r\nbuilder.&#x5B;To].Add(New MailBox(&quot;bob@mail.com&quot;, &quot;Bob&quot;))\r\n\r\nbuilder.PriorityHigh()\r\n\r\nDim email As IMail = builder.Create()\r\n\r\nUsing client As Smtp = New Smtp()\r\n    client.ConnectSSL(&quot;smtp.example.org&quot;)\r\n    client.UseBestLogin(&quot;alice@example.org&quot;, &quot;password&quot;)\r\n    client.SendMessage(email)\r\n    client.Close()\r\nEnd Using\r\n<\/pre>\n<p>Using fluent interface:<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\/\/ C# version:\r\n\r\nusing Fluent = Limilabs.Mail.Fluent;\r\n\r\nFluent.Mail.Html(&quot;&lt;html&gt;....&lt;\/html&gt;&quot;)\r\n    .Subject(&quot;This is important&quot;)\r\n    .To(&quot;to@example.com&quot;)\r\n    .From(&quot;from@example.com&quot;)\r\n    .PriorityHigh()\r\n    .UsingNewSmtp()\r\n    .Server(&quot;smtp.example.com&quot;)\r\n    .WithCredentials(&quot;user&quot;, &quot;password&quot;)\r\n    .WithSSL()\r\n    .Send();\r\n<\/pre>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\n' VB.NET version:\r\n\r\nImports Fluent = Limilabs.Mail.Fluent;\r\n\r\nFluent.Mail.Html(&quot;&lt;html&gt;....&lt;\/html&gt;&quot;) _\r\n    .Subject(&quot;This is important&quot;) _\r\n    .To(&quot;to@example.com&quot;) _\r\n    .From(&quot;from@example.com&quot;) _\r\n    .PriorityHigh() _\r\n    .UsingNewSmtp() _\r\n    .Server(&quot;smtp.example.com&quot;) _\r\n    .WithCredentials(&quot;user&quot;, &quot;password&quot;) _\r\n    .WithSSL() _\r\n    .Send()\r\n\r\n<\/pre>\n<p> <strong>PriorityLow()<\/strong> method is also available.<\/p>\n<p>It&#8217;s also really easy to check the email&#8217;s priority with <strong>GetGenericPriority<\/strong>.<br \/>\nGetGenericPriority checks Priority, Importance and X-Priority headers.<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\/\/ C# version:\r\n\r\nIMail email = new MailBuilder()\r\n    .CreateFromEml(imap.GetMessageByUID(uid))\r\n\r\nGenericPriority priority = email.GetGenericPriority();\r\nif (priority == GenericPriority.High)\r\n{\r\n    \/\/ Your code goes here\r\n}\r\n\r\n<\/pre>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\n' VB.NET version:\r\n\r\nDim email As IMail = New MailBuilder() _\r\n    .CreateFromEml(imap.GetMessageByUID(uid))\r\n\r\nDim priority As GenericPriority = email.GetGenericPriority()\r\n\r\nIf priority = GenericPriority.High Then\r\n    ' Your code goes here\r\nEnd If\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>There are several different email headers that make email high priority. Most correct is Priority header, but also Importance is used. Outlook uses X-Priority header. Mail.dll email library offers simple solution of this problem: PriorityHigh() method. The following code sends high priority email, that has all mentioned above headers set accordingly: \/\/ C# version: MailBuilder [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[15,33,50,57],"class_list":["post-1155","post","type-post","status-publish","format-standard","hentry","category-mail-dll","tag-c","tag-email-component","tag-smtp","tag-vb-net"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/1155"}],"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=1155"}],"version-history":[{"count":5,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/1155\/revisions"}],"predecessor-version":[{"id":5484,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/1155\/revisions\/5484"}],"wp:attachment":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/media?parent=1155"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/categories?post=1155"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/tags?post=1155"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}