.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> SQL Query >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Send Mail with attachment in SQL Server 2008

Posted By:Sasi Prabhu       Posted Date: June 23, 2011    Points: 40    Category: SQL Query    URL: http://www.dotnetspark.com  

Sending Mail with Attachment using SQL Query in SQL Server.
 


Step 1 :

Configure Database Mail

Refer :

http://www.dotnetspark.com/kb/4207-configure-database-mail-sql-server-2008.aspx

Step 2 :

Send Mail With Attachment


EXEC msdb.dbo.sp_send_dbmail @profile_name=, -- DatabaseMail ProfileName
  @recipients=,  -- To Address
  @subject=,  -- Mail Subject
  @body=, -- Mail Body
  @file_attachments= --File Location
 GO


Example :

EXEC msdb.dbo.sp_send_dbmail @profile_name='ProfileName',
  @recipients='SenderEmail@domain.com',
  @subject='Test message',
  @body='This is the body of the test message. Congrates Database Mail Received By you Successfully.',
  @file_attachments='C:\File.txt'
GO




     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend