{"id":3103,"date":"2022-04-08T11:00:29","date_gmt":"2022-04-08T04:00:29","guid":{"rendered":"https:\/\/www.sqlservertutorial.net\/?page_id=3103"},"modified":"2022-04-08T11:39:41","modified_gmt":"2022-04-08T04:39:41","slug":"sql-server-database-mail","status":"publish","type":"page","link":"https:\/\/www.sqlservertutorial.net\/sql-server-administration\/sql-server-database-mail\/","title":{"rendered":"SQL Server Database Mail"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you&#8217;ll learn how to configure database mail and send an email from SQL Server to users.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='introduction-to-the-sql-server-database-mail'>Introduction to the SQL Server Database Mail <a href=\"#introduction-to-the-sql-server-database-mail\" class=\"anchor\" id=\"introduction-to-the-sql-server-database-mail\" title=\"Anchor for Introduction to the SQL Server Database Mail\">#<\/a><\/h2>\n\n\n\n<p>Database email allows you to send email messages to users from the SQL Server Database Engine. The email message can be plain text or HTML and may include attach files.<\/p>\n\n\n\n<p>The Database Mail is reliable, scalable, secure, and supportive.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id='reliability'>Reliability <a href=\"#reliability\" class=\"anchor\" id=\"reliability\" title=\"Anchor for Reliability\">#<\/a><\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li>Database Mail uses SMTP to send email messages.<\/li><li>SQL Server uses a separate process to deliver email messages to minimize the performance impact on the server. SQL Server will queue the email messages even if the SMTP server is offline. The email message will be sent when the SMTP server comes online.<\/li><li>Database Mail can use multiple SMTP servers. If an SMTP server is unavailable, it&#8217;ll use the second SMPT server to send email messages.<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id='scalable'>Scalable <a href=\"#scalable\" class=\"anchor\" id=\"scalable\" title=\"Anchor for Scalable\">#<\/a><\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li>Database Mail sends email messages asynchronously in the background. To send an email message, you use the <code>sp_send_dbmail<\/code> stored procedure. This stored procedure adds a request to a Service Broker queue and returns immediately. The external email component receives the request and delivers the email message.<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id='security'>Security <a href=\"#security\" class=\"anchor\" id=\"security\" title=\"Anchor for Security\">#<\/a><\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li>The Database Mail is off by default. To send email messages, you must enable it first.<\/li><li>The user must be a member of the <strong>DatabaseMailUserRole<\/strong> database role in the <strong>msdb<\/strong> database to send an email.<\/li><li>Database Mail allows you to secure the mail profiles.<\/li><li>Database Mail allows you to configure the attached size limit and extension of attached files. If you want to attach a file from a folder to an email, the SQL Server engine account needs to have permission to access the file.<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id='supportability'>Supportability <a href=\"#supportability\" class=\"anchor\" id=\"supportability\" title=\"Anchor for Supportability\">#<\/a><\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li>Logging &#8211; Database Mail logs email activity to tables in the <code>msdb<\/code> <a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-administration\/sql-server-system-databases\/\">system database<\/a> and the Microsoft Windows application event log.<\/li><li>Auditing &#8211; Database Mail keeps copies of email messages and attachments in the <code>msdb<\/code> database.<\/li><li>Multiple email formats &#8211; Database Mail supports both plain text and HTML formats.<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id='configure-sql-server-database-mail'>Configure SQL Server Database Mail <a href=\"#configure-sql-server-database-mail\" class=\"anchor\" id=\"configure-sql-server-database-mail\" title=\"Anchor for Configure SQL Server Database Mail\">#<\/a><\/h2>\n\n\n\n<p>First, change the <code>Show Advanced<\/code> configuration setting to 1:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">sp_configure '<span class=\"hljs-keyword\">Show<\/span> <span class=\"hljs-keyword\">Advanced<\/span><span class=\"hljs-string\">', 1;\r\nreconfigure;<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>By doing this, you can view all global configuration settings of the current server using the <code>sp_configure<\/code> stored procedure:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">sp_configure<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Second, enable the Database Mail for the current SQL Server instance:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">sp_configure 'Database Mail XPs',1 \r\nreconfigure<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Third, create a Database Mail account using the <code>msdb.dbo.sysmail_add_account_sp<\/code> stored procedure:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">EXECUTE<\/span> msdb.dbo.sysmail_add_account_sp\r\n@account_name = <span class=\"hljs-string\">'Primary Account'<\/span>,\r\n@description = <span class=\"hljs-string\">'Account used by all mail profiles.'<\/span>,\r\n@email_address = <span class=\"hljs-string\">'alert@sqlservertutorial.net'<\/span>,\r\n@replyto_address = <span class=\"hljs-string\">'alert@sqlservertutorial.net'<\/span>,\r\n@display_name = <span class=\"hljs-string\">'Database Mail'<\/span>,\r\n@mailserver_name = <span class=\"hljs-string\">'smtp.sqlservertutorial.net'<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Fourth, create a Database Mail profile:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">EXECUTE<\/span> msdb.dbo.sysmail_add_profile_sp\r\n@profile_name = <span class=\"hljs-string\">'Public Profile'<\/span>,\r\n@description = <span class=\"hljs-string\">'public profile for all users'<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Fifth, add the account to the <code>Public Profile<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">EXECUTE<\/span> msdb.dbo.sysmail_add_profileaccount_sp\r\n@profile_name = <span class=\"hljs-string\">'Public Profile'<\/span>,\r\n@account_name = <span class=\"hljs-string\">'Primary Account'<\/span>,\r\n@sequence_number = <span class=\"hljs-number\">1<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Sixth, grant access to the profile to all <code>msdb<\/code> database users:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">EXECUTE<\/span> msdb.dbo.sysmail_add_principalprofile_sp\r\n@profile_name = <span class=\"hljs-string\">'public Profile'<\/span>,\r\n@principal_name = <span class=\"hljs-string\">'public'<\/span>,\r\n@is_default = <span class=\"hljs-number\">1<\/span>;\r<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\" id='send-email-using-database-mail'>Send email using Database Mail <a href=\"#send-email-using-database-mail\" class=\"anchor\" id=\"send-email-using-database-mail\" title=\"Anchor for Send email using Database Mail\">#<\/a><\/h2>\n\n\n\n<p>To send an email message, you use the <code>msdb.dbo.sp_send_dbmail<\/code> stored procedure.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id='1-sending-an-email-message-example'>1) Sending an email message example <a href=\"#1-sending-an-email-message-example\" class=\"anchor\" id=\"1-sending-an-email-message-example\" title=\"Anchor for 1) Sending an email message example\">#<\/a><\/h3>\n\n\n\n<p>The following example sends an email message to the email address <code>report@sqlservertutorial.net<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">EXEC msdb.dbo.sp_send_dbmail  \n    @recipients = 'report@sqlservertutorial.net',  \n    @body = 'This is a test message',  \n    @subject = 'Database Mail Test';<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\" id='2-sending-an-email-message-with-the-result-of-a-query-example'>2) Sending an email message with the result of a query example  <a href=\"#2-sending-an-email-message-with-the-result-of-a-query-example\" class=\"anchor\" id=\"2-sending-an-email-message-with-the-result-of-a-query-example\" title=\"Anchor for 2) Sending an email message with the result of a query example \">#<\/a><\/h3>\n\n\n\n<p>First, select the inventory for the products id 1 and 2:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span>\r\n  store_name,\r\n  product_name,\r\n  <span class=\"hljs-keyword\">SUM<\/span>(quantity)\r\n<span class=\"hljs-keyword\">FROM<\/span> sales.stores s\r\n<span class=\"hljs-keyword\">INNER<\/span> <span class=\"hljs-keyword\">JOIN<\/span> production.stocks i\r\n  <span class=\"hljs-keyword\">ON<\/span> i.store_id = s.store_id\r\n<span class=\"hljs-keyword\">INNER<\/span> <span class=\"hljs-keyword\">JOIN<\/span> production.products p\r\n  <span class=\"hljs-keyword\">ON<\/span> p.product_id = i.product_id\r\n<span class=\"hljs-keyword\">WHERE<\/span> p.product_id <span class=\"hljs-keyword\">IN<\/span> (<span class=\"hljs-number\">1<\/span>, <span class=\"hljs-number\">2<\/span>)\r\n<span class=\"hljs-keyword\">GROUP<\/span> <span class=\"hljs-keyword\">BY<\/span> store_name,\r\n         product_name;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Output:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"581\" height=\"171\" src=\"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/SQL-Server-Database-Mail-Example.png\" alt=\"\" class=\"wp-image-3116\" srcset=\"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/SQL-Server-Database-Mail-Example.png 581w, https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/SQL-Server-Database-Mail-Example-300x88.png 300w\" sizes=\"auto, (max-width: 581px) 100vw, 581px\" \/><\/figure>\n\n\n\n<p>Second, convert the query result into an HTML table body. Each row in the result set is an HTML table row with the <code>&lt;tr><\/code> tag:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span>\r\n  <span class=\"hljs-keyword\">CAST<\/span>((<span class=\"hljs-keyword\">SELECT<\/span>\r\n    td = store_name,\r\n    <span class=\"hljs-string\">''<\/span>,\r\n    td = product_name,\r\n    <span class=\"hljs-string\">''<\/span>,\r\n    td = <span class=\"hljs-keyword\">SUM<\/span>(quantity),\r\n    <span class=\"hljs-string\">''<\/span>\r\n  <span class=\"hljs-keyword\">FROM<\/span> sales.stores s\r\n  <span class=\"hljs-keyword\">INNER<\/span> <span class=\"hljs-keyword\">JOIN<\/span> production.stocks i\r\n    <span class=\"hljs-keyword\">ON<\/span> i.store_id = s.store_id\r\n  <span class=\"hljs-keyword\">INNER<\/span> <span class=\"hljs-keyword\">JOIN<\/span> production.products p\r\n    <span class=\"hljs-keyword\">ON<\/span> p.product_id = i.product_id\r\n  <span class=\"hljs-keyword\">WHERE<\/span> p.product_id <span class=\"hljs-keyword\">IN<\/span> (<span class=\"hljs-number\">1<\/span>, <span class=\"hljs-number\">2<\/span>)\r\n  <span class=\"hljs-keyword\">GROUP<\/span> <span class=\"hljs-keyword\">BY<\/span> store_name,\r\n           product_name\r\n  <span class=\"hljs-keyword\">FOR<\/span> <span class=\"hljs-keyword\">xml<\/span> <span class=\"hljs-keyword\">PATH<\/span> (<span class=\"hljs-string\">'tr'<\/span>), <span class=\"hljs-keyword\">TYPE<\/span>)\r\n  <span class=\"hljs-keyword\">AS<\/span> <span class=\"hljs-keyword\">nvarchar<\/span>(<span class=\"hljs-keyword\">max<\/span>));<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Third, convert the HTML table body into text:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-11\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">DECLARE<\/span> @tableHTML <span class=\"hljs-keyword\">NVARCHAR<\/span>(<span class=\"hljs-keyword\">MAX<\/span>);  \n  \n<span class=\"hljs-keyword\">SET<\/span> @tableHTML =  \n    N<span class=\"hljs-string\">'&lt;h1&gt;Inventory Report&lt;\/h1&gt;'<\/span> +  \n    N<span class=\"hljs-string\">'&lt;table border=\"1\"&gt;'<\/span> +  \n    N<span class=\"hljs-string\">'&lt;tr&gt;&lt;thead&gt;&lt;th&gt;Store Name&lt;\/th&gt;&lt;th&gt;Product&lt;\/th&gt;&lt;th&gt;Total Quantity&lt;\/th&gt;&lt;\/thead&gt;&lt;tbody&gt;'<\/span> +  \n    <span class=\"hljs-keyword\">CAST<\/span> ( (  \n\t\t\t<span class=\"hljs-keyword\">SELECT<\/span>\n\t\t\t  td=store_name,<span class=\"hljs-string\">''<\/span>,\n\t\t\t  td=product_name,<span class=\"hljs-string\">''<\/span>,\n\t\t\t  td=<span class=\"hljs-keyword\">SUM<\/span>(quantity),<span class=\"hljs-string\">''<\/span>\n\t\t\t<span class=\"hljs-keyword\">FROM<\/span> sales.stores s\n\t\t\t<span class=\"hljs-keyword\">INNER<\/span> <span class=\"hljs-keyword\">JOIN<\/span> production.stocks i\n\t\t\t  <span class=\"hljs-keyword\">ON<\/span> i.store_id = s.store_id\n\t\t\t<span class=\"hljs-keyword\">INNER<\/span> <span class=\"hljs-keyword\">JOIN<\/span> production.products p\n\t\t\t  <span class=\"hljs-keyword\">ON<\/span> p.product_id = i.product_id\n\t\t\t<span class=\"hljs-keyword\">WHERE<\/span> p.product_id <span class=\"hljs-keyword\">IN<\/span> (<span class=\"hljs-number\">1<\/span>, <span class=\"hljs-number\">2<\/span>)\n\t\t\t<span class=\"hljs-keyword\">GROUP<\/span> <span class=\"hljs-keyword\">BY<\/span> store_name,\n\t\t\t\t\t product_name\n\t\t\t<span class=\"hljs-keyword\">FOR<\/span> <span class=\"hljs-keyword\">XML<\/span> <span class=\"hljs-keyword\">PATH<\/span>(<span class=\"hljs-string\">'tr'<\/span>), <span class=\"hljs-keyword\">TYPE<\/span> \n\t) <span class=\"hljs-keyword\">AS<\/span> <span class=\"hljs-keyword\">NVARCHAR<\/span>(<span class=\"hljs-keyword\">MAX<\/span>) ) +  \n    N<span class=\"hljs-string\">'&lt;\/tbody&gt;&lt;\/table&gt;'<\/span> ;  \n\n<span class=\"hljs-keyword\">SELECT<\/span> @tableHTML;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Finally, send an email message to the email <code>report@sqlservertutorial.net<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-12\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">EXEC msdb.dbo.sp_send_dbmail \n    @recipients='report@sqlservertutorial.net',  \r\n    @subject = 'Inventory List',  \r\n    @body = @tableHTML,  \r\n    @body_format = 'HTML';  <\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-12\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\" id='summary'>Summary <a href=\"#summary\" class=\"anchor\" id=\"summary\" title=\"Anchor for Summary\">#<\/a><\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>Database Mail allows you to send email messages using SQL Server Database Engine.<\/li><li>Use the <code>msdb.dbo.sp_send_dbmail<\/code>  stored procedure to send an email message.<\/li><\/ul>\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Was this tutorial helpful?<\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"3103\"\n\t\t\t\tdata-post-url=\"https:\/\/www.sqlservertutorial.net\/sql-server-administration\/sql-server-database-mail\/\"\n\t\t\t\tdata-post-title=\"SQL Server Database Mail\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"3103\"\n\t\t\t\tdata-post-url=\"https:\/\/www.sqlservertutorial.net\/sql-server-administration\/sql-server-database-mail\/\"\n\t\t\t\tdata-post-title=\"SQL Server Database Mail\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\n\t\t\t<button class=\"btn btn-primary wth-btn-submit\">Send<\/button>\n\t\t\t<button class=\"btn wth-btn-cancel\">Cancel<\/button>\n\t\t\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>in this tutorial, you&#8217;ll learn how to configure database mail and send an email from SQL Server to users.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":2903,"menu_order":18,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-3103","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>SQL Server Database Mail<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.sqlservertutorial.net\/sql-server-administration\/sql-server-database-mail\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SQL Server Database Mail\" \/>\n<meta property=\"og:description\" content=\"in this tutorial, you&#039;ll learn how to configure database mail and send an email from SQL Server to users.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlservertutorial.net\/sql-server-administration\/sql-server-database-mail\/\" \/>\n<meta property=\"og:site_name\" content=\"SQL Server Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2022-04-08T04:39:41+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/SQL-Server-Database-Mail-Example.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-administration\\\/sql-server-database-mail\\\/\",\"url\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-administration\\\/sql-server-database-mail\\\/\",\"name\":\"SQL Server Database Mail\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-administration\\\/sql-server-database-mail\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-administration\\\/sql-server-database-mail\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/wp-content\\\/uploads\\\/SQL-Server-Database-Mail-Example.png\",\"datePublished\":\"2022-04-08T04:00:29+00:00\",\"dateModified\":\"2022-04-08T04:39:41+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-administration\\\/sql-server-database-mail\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-administration\\\/sql-server-database-mail\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-administration\\\/sql-server-database-mail\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/wp-content\\\/uploads\\\/SQL-Server-Database-Mail-Example.png\",\"contentUrl\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/wp-content\\\/uploads\\\/SQL-Server-Database-Mail-Example.png\",\"width\":581,\"height\":171},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-administration\\\/sql-server-database-mail\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SQL Server Administration\",\"item\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-administration\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"SQL Server Database Mail\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/#website\",\"url\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/\",\"name\":\"SQL Server Tutorial\",\"description\":\"The Practical SQL Server Tutorial\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"SQL Server Database Mail","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.sqlservertutorial.net\/sql-server-administration\/sql-server-database-mail\/","og_locale":"en_US","og_type":"article","og_title":"SQL Server Database Mail","og_description":"in this tutorial, you'll learn how to configure database mail and send an email from SQL Server to users.","og_url":"https:\/\/www.sqlservertutorial.net\/sql-server-administration\/sql-server-database-mail\/","og_site_name":"SQL Server Tutorial","article_modified_time":"2022-04-08T04:39:41+00:00","og_image":[{"url":"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/SQL-Server-Database-Mail-Example.png","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqlservertutorial.net\/sql-server-administration\/sql-server-database-mail\/","url":"https:\/\/www.sqlservertutorial.net\/sql-server-administration\/sql-server-database-mail\/","name":"SQL Server Database Mail","isPartOf":{"@id":"https:\/\/www.sqlservertutorial.net\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.sqlservertutorial.net\/sql-server-administration\/sql-server-database-mail\/#primaryimage"},"image":{"@id":"https:\/\/www.sqlservertutorial.net\/sql-server-administration\/sql-server-database-mail\/#primaryimage"},"thumbnailUrl":"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/SQL-Server-Database-Mail-Example.png","datePublished":"2022-04-08T04:00:29+00:00","dateModified":"2022-04-08T04:39:41+00:00","breadcrumb":{"@id":"https:\/\/www.sqlservertutorial.net\/sql-server-administration\/sql-server-database-mail\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlservertutorial.net\/sql-server-administration\/sql-server-database-mail\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqlservertutorial.net\/sql-server-administration\/sql-server-database-mail\/#primaryimage","url":"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/SQL-Server-Database-Mail-Example.png","contentUrl":"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/SQL-Server-Database-Mail-Example.png","width":581,"height":171},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlservertutorial.net\/sql-server-administration\/sql-server-database-mail\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlservertutorial.net\/"},{"@type":"ListItem","position":2,"name":"SQL Server Administration","item":"https:\/\/www.sqlservertutorial.net\/sql-server-administration\/"},{"@type":"ListItem","position":3,"name":"SQL Server Database Mail"}]},{"@type":"WebSite","@id":"https:\/\/www.sqlservertutorial.net\/#website","url":"https:\/\/www.sqlservertutorial.net\/","name":"SQL Server Tutorial","description":"The Practical SQL Server Tutorial","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqlservertutorial.net\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/3103","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/comments?post=3103"}],"version-history":[{"count":4,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/3103\/revisions"}],"predecessor-version":[{"id":3124,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/3103\/revisions\/3124"}],"up":[{"embeddable":true,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/2903"}],"wp:attachment":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/media?parent=3103"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}