We can send email from SQL Server in HTML format by using dbo.sp_send_dbmail stored procedure. To send email in HTML format, we have to build the body of email with HTML Tags. The below code can be used to send basis HTML formatted email. If you want to loop through some results of table and send in HTML formatted email. You can use This script for looping ( TSQL Cursor) and build the body by using below script.
--Get the Profile Name that you want to use
--select * from msdb..sysmail_profile
DECLARE @Recipients VARCHAR(200) SET @Recipients='aamirwarraich2001@gmail.com' DECLARE @Subject VARCHAR(100) SET @Subject='Test Email Subject' DECLARE @Body NVARCHAR(2000)
DECLARE @ProfileName VARCHAR(100) SET @ProfileName='EmailProfileName'
SET @Body=N' <html> <head> <meta http-equiv=Content-Type content="text/html; charset=windows-1252"> <style>p{font-size:10.0pt;font-family:Calibri,"Arial","serif";}</style> </head> <body> <p>Hello All,</p> <p>Sql Age is the blog spot to learn and share Information, Scenarios, Real Time Examples about SQL Server,<br /> Transact-SQL (TSQL), SQL Server Database Administration (SQL DBA), Business Intelligence (BI),<br /> SQL Server Integration Services (SSIS), SQL Server Reporting Services (SSRS) and Data Warehouse (DWH) Concepts.</p> <p>Thank you,<br /> Development Team<br /> <a href="http://sqlage.blogspot.com/"><b>sqlage.blogspot.com</b></a><br /> </p> </body> </html>' EXEC msdb.dbo.sp_send_dbmail @profile_name =@ProfileName, @recipients = @Recipients, @subject = @Subject, @body = @Body, @body_format = 'HTML'
PPC Service in Delhi
ReplyDeletePPC Companies in Delhi
SEO Company in Delhi
SEO Company in Delhi NCR
SMO Company in Delhi
SMO Company in India
Wow! Such an amazing and helpful post this is. I really really love it. It's so good and so awesome. I am just amazed. I hope that you continue to do your work like this in the future also Site Tips Login
ReplyDeleteHello fellas, I am back with yet another tutorial. In today’s tutorial I will show you how to make an account in hotmail and make a successful Hotmail Login. So let’s get started.
ReplyDeleteIEEE Final Year Project centers make amazing deep learning final year projects ideas for final year students Final Year Projects for CSE to training and develop their deep learning experience and talents.
ReplyDeleteIEEE Final Year projects Project Centers in India are consistently sought after. Final Year Students Projects take a shot at them to improve their aptitudes, while specialists like the enjoyment in interfering with innovation.
corporate training in chennai corporate training in chennai
corporate training companies in india corporate training companies in india
corporate training companies in chennai corporate training companies in chennai
I have read your blog its very attractive and impressive. I like it your blog. Digital Marketing Company in Chennai
Mua vé tại Aivivu, tham khảo
ReplyDeletevé máy bay từ singapore về việt nam giá rẻ
vé máy bay từ hải phòng về sài gòn
vé máy bay đi hà nội bao nhiêu tiền
vé máy bay hà nội nha trang khứ hồi
vé máy bay đi phù cát
Thanks For the Great Content.
ReplyDeleteBest Workday Online Training in India
Workday Online Training in Hyderabad