I have the below SQL which runs daily in a daily job. I want the results in the email to have a line break at the end of each row from the query result. Currently the email puts everything on the same line rather than one line per row in the SQL query. G if the query returns 10 rows, it should put it onto 10 lines in the email and not one continuous line. Can you try with the below query. How are we doing? Please help us improve Stack Overflow. Take our short survey.
Stack Overflow for Teams — Collaborate and share knowledge with a private group. Its only goal is to create a message object with all of the fields one would type in when sending an email message by hand and put it into a service broker queue in msdb for the mail service to pick up.
When it successfully does this, the id of the object in the queue is returned. It does not offer many of the features traditional email would such as cc and bcc for recipients and formatting options. This is the name of the mail profile to be used to send the message.
The procedure will use the default mail profile if not included in the call. If there is not a default profile, then this becomes a de facto required parameter. The data type is sysname or nvarchar The next group of parameters are traditional email fields. While none of the recipient address lists are explicitly required, at least one of them must be included for the message to have anywhere to go.
The final group of parameters has to do with running a query during execution and will be covered in depth later in the tip. This procedure does not ask for a to, cc, or bcc group of recipient email addresses. This is accomplished by using another group of parameters. Consider this sample execution. Notice that it contains both a body and a query and that the query results appear after the body message. The body is optional and without it the email will contain only the results of the query.
That works great for smaller messages, but can become cumbersome to read when the output is larger. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name.
Email Required, but never shown. The Overflow Blog. Does ES6 make JavaScript frameworks obsolete? Podcast Do polyglots have an edge when it comes to mastering programming Featured on Meta. Now live: A fully responsive profile. Linked 3. Related 3. Hot Network Questions. Note : The credential dialog can pop-up more than one time. Just click the OK button each time, until the server stops asking for login information. This usually happens when something is not configured right e.
In this case, the first task failed and sending test e-mail message failed as well right afterward:. Some applications and devices use less secure sign-in technology, which makes their respective accounts more vulnerable and Gmail will block these sign-in requests.
By default, access for these applications is turned off, but we can also turn access on to use them despite the risks.
In this case, we also have to. This can be solved by logging into Gmail account and making sure that Less secure apps option is enabled for the desired account. Go to the Less secure apps section of the Gmail account and enable access for less secure applications. Note : This setting is not available for accounts with 2-Step Verification enabled. Such accounts require an application-specific password for less secure apps access.
Since this account has 2-Step Verification enabled, we have to turn it off, so we can continue further. A pop-up dialog will appear informing the user about security and vulnerability. We are aware of this, so just click the Turn off button to continue:. Now we can go back to the Less secure apps section and allow access for less secure applications:.
Back to Outlook, click the Next button once again to test e-mail account settings and finally a message without errors. Both tasks completed successfully:. The test e-mail message is also delivered successfully which means that sending another test e-mail from Database Mail should work this time:. There is only one way to find out. Go back to SSMS and execute the code for sending the test e-mail:.
Unfortunately, even after all this trouble, the test e-mail is not getting through. A quick look at the log files shows another error message of another type:. Sending Mail using Account 10 T Exception Message: Cannot send mails to the mail server. Execute the code from below:.
Everything looks good, but the e-mail is still not getting out.
0コメント