question

Almontejr avatar image
Almontejr asked

How to send an email from mssql when the email addresses are in the results of the query

I have a table that contains the order status and email address , If I do a select * statement this is my output Name. Email Adress Approval code Order states. Qty tickets. Juan Rivera. Juan @anyemail.com. Null. 1 50 Maria Rosales Maria @anyemail.com. 5567657. 1. 25 Jose Almonte. Jose@anyemail.com. Null. 1. 10 What I would like to do is run a stored procedure everynight and send an email to every user that has a null in the approval code, for example : Dear : Jose , We noticed that your order does not contain an approval code , this order is scheduled to be canceled unless an approval code is entered in the next 72 hours. Thanks you Is this possible ?
sql-server-2008email
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
sp_lock avatar image
sp_lock answered
HI You should be able to use the [sp_send_dbmail][1]. Build your email up on the fly. We have in the past built up HTML as it can be made to look better than plain text, especially when you require formatting. [1]: http://msdn.microsoft.com/en-us/library/ms190307.aspx
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.