August 2, 2011 at 11:45 pm
Hi
I want to send personalized emails with an attachment to clients, can SQL do mail merge, I have all the addresses in a SQL database
August 3, 2011 at 1:22 am
This was removed by the editor as SPAM
August 4, 2011 at 7:53 am
Use Database Mail Configuration Wizard to set up database mail.
Here is the syntax of the send statement:
sp_send_dbmail [ [ @profile_name = ] 'profile_name' ]
[ , [ @recipients = ] 'recipients [ ; ...n ]' ]
[ , [ @copy_recipients = ] 'copy_recipient [ ; ...n ]' ]
[ , [ @blind_copy_recipients = ] 'blind_copy_recipient [ ; ...n ]' ]
[ , [ @subject = ] 'subject' ]
[ , [ @body = ] 'body' ]
[ , [ @body_format = ] 'body_format' ]
[ , [ @importance = ] 'importance' ]
[ , [ @sensitivity = ] 'sensitivity' ]
[ , [ @file_attachments = ] 'attachment [ ; ...n ]' ]
[ , [ @query = ] 'query' ]
[ , [ @execute_query_database = ] 'execute_query_database' ]
[ , [ @attach_query_result_as_file = ] attach_query_result_as_file ]
[ , [ @query_attachment_filename = ] query_attachment_filename ]
[ , [ @query_result_header = ] query_result_header ]
[ , [ @query_result_width = ] query_result_width ]
[ , [ @query_result_separator = ] 'query_result_separator' ]
[ , [ @exclude_query_output = ] exclude_query_output ]
[ , [ @append_query_error = ] append_query_error ]
[ , [ @query_no_truncate = ] query_no_truncate ]
[ , [ @query_result_no_padding = ] query_result_no_padding ]
[ , [ @mailitem_id = ] mailitem_id ] [ OUTPUT ]
Note that by default, attachment size is limited to 1 mb. Can change.
Use this to get the max size:
EXECUTE msdb.dbo.sysmail_help_configure_sp ;
Syntax to set the new limit to 2 mb:
EXECUTE msdb.dbo.sysmail_configure_sp
'MaxFileSize', '2097152' ;
Here is a sample call for a simple message:
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'SQL Server Mail Profile', --Must be exactly how it was set up in the configuration wizard
@recipients = 'recipient@theircompany.com',
@body = 'The backup job succeeded!!!!!!',
@subject = 'Job Succeeded' ;
Bob L
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply