C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » Databases »

Sp_send_dbmail in SQL Server


Posted Date: 25 Sep 2008    Resource Type: Articles    Category: Databases
Author: KavithaMember Level: Silver    
Rating: 1 out of 5Points: 8



This Stored procedure is used for sending mail from SQL server. This Procedure is available in msdb database.It is used to sends an email message to the specified person(receipients).The message may include a query result set,file attachment and query result as a file. When mail is successfully placed in the Databse Mail Queue ,sp_send_dbmail returns the mailitem_id of the message.

Before use,Database Mail must be enabled using the Databse Mail Configuration.The Stored procedure sp_send_dbmail does not support mail message without no content, To send an email,you should specify at least one of body of the message,subject,Query,file attachment etc. otherwise return an error.

When no profile is specified,sp_send_dbmail uses a default profile, If the user sending the mail message has a private profile, The database Mial uses that profile.If the user has no profile sp-send_dbmailuses default public profile. If there is no prfile available in mail, sp_send_db_mail returns an error.

Execute permissions for sp_send_dbmail default to all members of the DatabaseMailUser databse role in msdb database. When the user sending the message does not have permission to use the profile for request, sp_send_dbmail returns an error and does not send the mail message. The mail message can be send Text or HTML format.

Syntax:
------

sp_send_dbmail [@profile_name =] 'profile_name',
[@receipients =] 'receipient_name',
[@copy_receipients=] 'copy_receipients',
[@blind_copy_receipients =] 'blind_copy',
[@subject =] 'subject',
[@body=] 'body',
[@body_format=] 'body format',
[@importance =] 'importance',
[@sensititvity=] 'sensitivity',
[@file attachments] 'file_path',
[@query=] 'sql query',
[@execute_query_database=] 'execute',
[@attach_query_result_as_file=] result as a file,
[query_attachment_filename=] filename,
[@query_result_header=] Result header,
[@query_result_width=] width,
[@query_result_separator=] esult as a separator',
[exclude_query_output=] query_output,
[@append_query_error =] append',
[@query_no_truncate=] 'Query Truncate',
[@mailitem_id=] mailitem_id [output]


Then exec sp_send_dbmail

We will get output through mail.


Regards,
Kavitha Premkumar



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Send_dbmail  .  Msdb..send_dbmail  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Types of stored procedures
Previous Resource: Database Normalization
Return to Discussion Resource Index
Post New Resource
Category: Databases


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use