{"id":55492,"date":"2023-06-07T14:46:33","date_gmt":"2023-06-07T13:46:33","guid":{"rendered":"https:\/\/arquiconsult.com\/?p=55492"},"modified":"2024-10-23T10:37:52","modified_gmt":"2024-10-23T09:37:52","slug":"bc-smtp-email-setup-and-email-scenarios","status":"publish","type":"post","link":"https:\/\/arquiconsult.com\/en\/bc-smtp-email-setup-and-email-scenarios\/","title":{"rendered":"#041 BC SMTP EMAIL: SETUP AND EMAIL SCENARIOS"},"content":{"rendered":"<div class=\"services_vertical horizontal_services row\" style=\"background-color: #f7f7f7; padding: 25px; border-radius: 5px; text-align: justify;\">\n<p>In the newer versions of Business Central, the process of sending emails through SMTP differs from the one that was available in NAV due to the disappearance of codeunit 400 \u201cSMTP Mail\u201d. Instead, Microsoft provides the codeunits \u201cEmail\u201d and \u201cEmail Message\u201d and the enum \u201cEmail Scenarios\u201d. Next, it will be shown how to code and configure a simple example of sending emails.<\/p>\n<\/div>\n<p>&nbsp;<\/p>\n<p>Firstly, it is made an extension to the enum \u201cEmail Scenario\u201d in which are added all the scenarios intended. It should be taken into consideration that one must have as many scenarios as combinations of recipient\/subject\/body (although it is advised to have as many as combinations of recipient\/subject\/body\/attachment).<\/p>\n<p><img loading=\"lazy\" class=\"size-full wp-image-55498 aligncenter\" src=\"https:\/\/arquiconsult.com\/wp-content\/uploads\/2023\/07\/Firstly-it-is-made-an-extension-to-the-enum-Email-Scenario.png\" alt=\"Firstly, it is made an extension to the enum \u201cEmail Scenario\u201d\" width=\"485\" height=\"289\" srcset=\"https:\/\/arquiconsult.com\/wp-content\/uploads\/2023\/07\/Firstly-it-is-made-an-extension-to-the-enum-Email-Scenario.png 485w, https:\/\/arquiconsult.com\/wp-content\/uploads\/2023\/07\/Firstly-it-is-made-an-extension-to-the-enum-Email-Scenario-320x191.png 320w, https:\/\/arquiconsult.com\/wp-content\/uploads\/2023\/07\/Firstly-it-is-made-an-extension-to-the-enum-Email-Scenario-480x286.png 480w\" sizes=\"(max-width: 485px) 100vw, 485px\" title=\"-\"><\/p>\n<p>&nbsp;<\/p>\n<p>Secondly, it is created the email sending process itself by instantiating the \u201cEmail Message\u201d codeunit, by calling the Create procedure with the Recipient, Subject, Body and\u00a0 HtmlFormatted parameters respectively. Then, this email is sent by the \u201cEmail\u201d codeunit in a chosen scenario.<\/p>\n<p><img loading=\"lazy\" class=\"size-medium wp-image-55500 aligncenter\" src=\"https:\/\/arquiconsult.com\/wp-content\/uploads\/2023\/07\/Secondly-it-is-created-the-email-sending-process-itself-by-instantiating-the-Email-Message-codeunit-640x480.png\" alt=\"Secondly, it is created the email sending process itself by instantiating the \u201cEmail Message\u201d codeunit,\" width=\"640\" height=\"480\" srcset=\"https:\/\/arquiconsult.com\/wp-content\/uploads\/2023\/07\/Secondly-it-is-created-the-email-sending-process-itself-by-instantiating-the-Email-Message-codeunit-640x480.png 640w, https:\/\/arquiconsult.com\/wp-content\/uploads\/2023\/07\/Secondly-it-is-created-the-email-sending-process-itself-by-instantiating-the-Email-Message-codeunit-768x576.png 768w, https:\/\/arquiconsult.com\/wp-content\/uploads\/2023\/07\/Secondly-it-is-created-the-email-sending-process-itself-by-instantiating-the-Email-Message-codeunit-320x240.png 320w, https:\/\/arquiconsult.com\/wp-content\/uploads\/2023\/07\/Secondly-it-is-created-the-email-sending-process-itself-by-instantiating-the-Email-Message-codeunit-480x360.png 480w, https:\/\/arquiconsult.com\/wp-content\/uploads\/2023\/07\/Secondly-it-is-created-the-email-sending-process-itself-by-instantiating-the-Email-Message-codeunit-800x600.png 800w, https:\/\/arquiconsult.com\/wp-content\/uploads\/2023\/07\/Secondly-it-is-created-the-email-sending-process-itself-by-instantiating-the-Email-Message-codeunit.png 927w\" sizes=\"(max-width: 640px) 100vw, 640px\" title=\"-\"><\/p>\n<p>&nbsp;<\/p>\n<p>The next step is to set up the accounts from which the emails will be sent. To demonstrate it, two accounts were configured in the \u201cEmail Accounts\u201d page. The steps are as follows:<\/p>\n<ul>\n<li>Click the action \u201cAdd an email account\u201d<\/li>\n<li>Start the wizard<\/li>\n<li>Select SMTP Account Type<\/li>\n<li>Fill the credentials and Sender information.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" class=\" wp-image-55503 aligncenter\" src=\"https:\/\/arquiconsult.com\/wp-content\/uploads\/2023\/07\/3-640x287.png\" alt=\"3\" width=\"484\" height=\"217\" srcset=\"https:\/\/arquiconsult.com\/wp-content\/uploads\/2023\/07\/3-640x287.png 640w, https:\/\/arquiconsult.com\/wp-content\/uploads\/2023\/07\/3-320x144.png 320w, https:\/\/arquiconsult.com\/wp-content\/uploads\/2023\/07\/3-480x215.png 480w, https:\/\/arquiconsult.com\/wp-content\/uploads\/2023\/07\/3.png 744w\" sizes=\"(max-width: 484px) 100vw, 484px\" title=\"-\"><\/p>\n<p>&nbsp;<\/p>\n<p>The \u201cServer Url\u201d, \u201cServer Port\u201d, \u201cAuthentication\u201d, \u201cUser Name\u201d and \u201cPassword\u201d are set as they were in NAV. The \u201cSender Name\u201d and the \u201cEmail Address\u201d identify the e-mail from which the e-mails will be sent.<\/p>\n<p>&nbsp;<\/p>\n<p>Notice that, although both accounts are configured with the same SMTP credentials (namely the username <a href=\"mailto:noreply@arquiconsult.com\">noreply@arquiconsult.com<\/a> and respective password) the emails are sent from the email set on the field \u201cEmail Address\u201d.<\/p>\n<p>&nbsp;<\/p>\n<p>In the \u201cEmail Accounts\u201d page, the \u201cEmail Scenarios\u201d are then assigned to a certain account by selecting \u201cEmail Scenarios\u201d on the Navigate bar and then choosing \u201cAssign Email Scenarios\u201d. Take into consideration that a certain scenario can only be assigned to one \u201cEmail Account\u201d.<\/p>\n<p>As a result, in this simple example, the Vendors would receive an email from <a href=\"mailto:info@arquiconsult.come\">info@arquiconsult.com<\/a> stating that their \u2018Phone No.\u2019 was missing.<\/p>\n<p>&nbsp;<\/p>\n<!--themify_builder_content-->\n<div id=\"themify_builder_content-55492\" data-postid=\"55492\" class=\"themify_builder_content themify_builder_content-55492 themify_builder tf_clear\">\n    \t<!-- module_row -->\n\t<div  data-lazy=\"1\" class=\"module_row themify_builder_row tb_nus1581 tb_first tf_clearfix\">\n\t    \t\t<div class=\"row_inner col_align_top col-count-1 tf_box tf_w tf_rel\">\n\t\t\t<div  data-lazy=\"1\" class=\"module_column tb-column col-full first tb_cai8581 tf_box\">\n\t\t\t    \t        <div class=\"tb-column-inner tf_box tf_w\">\n\t\t    <!-- module text -->\n<div  class=\"module module-text tb_9tkr581 arquitps-data  \" data-lazy=\"1\">\n        <div  class=\"tb_text_wrap\">\n    <p><script>\njQuery(\".tbp_post_month:contains(Janeiro)\").html(\"January\");\n\njQuery(\".tbp_post_month:contains(Fevereiro)\").html(\"February\");\n\n\njQuery(\".tbp_post_month:contains(Mar\u00e7o)\").html(\"March\");\n\n\njQuery(\".tbp_post_month:contains(Abril)\").html(\"April\");\n\n\njQuery(\".tbp_post_month:contains(Maio)\").html(\"May\");\n\n\njQuery(\".tbp_post_month:contains(Junho)\").html(\"June\");\n\n\njQuery(\".tbp_post_month:contains(Julho)\").html(\"July\");\n\njQuery(\".tbp_post_month:contains(Agosto)\").html(\"August\");\n\njQuery(\".tbp_post_month:contains(Setembro)\").html(\"September\");\n\njQuery(\".tbp_post_month:contains(Outubro)\").html(\"October\");\n\njQuery(\".tbp_post_month:contains(Novembro)\").html(\"November\");\n\njQuery(\".tbp_post_month:contains(Dezembro)\").html(\"December\");\t\n\n\n\n<\/script><\/p>    <\/div>\n<\/div>\n<!-- \/module text -->\t        <\/div>\n\t    \t<\/div>\n\t\t    <\/div>\n\t    <!-- \/row_inner -->\n\t<\/div>\n\t<!-- \/module_row -->\n\t\t<!-- module_row -->\n\t<div  data-anchor=\"sucesso\" data-hide-anchor=\"1\" data-lazy=\"1\" class=\"module_row themify_builder_row sucesso repeat tb_has_section tb_section-sucesso tb_xddz713 tf_clearfix\" >\n\t    \t\t<div class=\"row_inner col_align_top col-count-1 tf_box tf_w tf_rel\">\n\t\t\t<div  data-lazy=\"1\" class=\"module_column tb-column col-full first tb_pi5s714 tf_box\">\n\t\t\t    \t        <div class=\"tb-column-inner tf_box tf_w\">\n\t\t    <!-- module buttons -->\n<div  class=\"module module-buttons tb_zshl714 buttons-horizontal transparent popmake-24705 large circle tf_textc\" data-lazy=\"1\">\n    \t<div class=\"module-buttons-item tf_inline_b\">\n\t\t\t\t\t\t\t<a href=\"#\" class=\"ui builder_button tb_default_color\" >\n\t\t\t\t\t\t\t\t\t\t\t<span class=\"tf_inline_b tf_vmiddle\">Give as a Feedback and Suggest Questions<\/span>\n\t\t\t\t\t\t\t\t\t\t\t<\/a>\n\t\t\t    \t<\/div>\n\t<\/div>\n<!-- \/module buttons -->\n\t        <\/div>\n\t    \t<\/div>\n\t\t    <\/div>\n\t    <!-- \/row_inner -->\n\t<\/div>\n\t<!-- \/module_row -->\n\t<\/div>\n<!--\/themify_builder_content-->\n","protected":false},"excerpt":{"rendered":"<p>In the newer versions of Business Central, the process of sending emails through SMTP differs from the one that was available in NAV due to the disappearance of codeunit 400 \u201cSMTP Mail\u201d. Instead, Microsoft provides the codeunits \u201cEmail\u201d and \u201cEmail Message\u201d and the enum \u201cEmail Scenarios\u201d. Next, it will be shown how to code and [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":55603,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2099,2124],"tags":[2388,2076,2389,2390],"acf":[],"_links":{"self":[{"href":"https:\/\/arquiconsult.com\/en\/wp-json\/wp\/v2\/posts\/55492"}],"collection":[{"href":"https:\/\/arquiconsult.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/arquiconsult.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/arquiconsult.com\/en\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/arquiconsult.com\/en\/wp-json\/wp\/v2\/comments?post=55492"}],"version-history":[{"count":0,"href":"https:\/\/arquiconsult.com\/en\/wp-json\/wp\/v2\/posts\/55492\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/arquiconsult.com\/en\/wp-json\/wp\/v2\/media\/55603"}],"wp:attachment":[{"href":"https:\/\/arquiconsult.com\/en\/wp-json\/wp\/v2\/media?parent=55492"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/arquiconsult.com\/en\/wp-json\/wp\/v2\/categories?post=55492"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/arquiconsult.com\/en\/wp-json\/wp\/v2\/tags?post=55492"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}