Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
Log in  ::  Register  ::  Not logged in

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Send Mail

By Scott Williams,

Syntax for sp_send_cdosysmail (based on CDOSYS):
Exec master.dbo.sp_send_cdosysmail
@To (varchar(2048)) - Recipient e-mail address list separating each with a ';'
or a ','. Use a '?' to return the syntax.
@Body (varchar(8000)) - Text body; use embedded char(13) + char(10)
for carriage returns. The default is nothing
@Subject (varchar(255))) - E-mail subject. The default is a message from
@Attachments (varchar(1024)) - Attachment list separating each with a ';'.
The default is no attachments.
@From (varchar(128)) - Sender list defaulted to @@ServerName.
@CC (varchar(2048)) - CC list separating each with a ';' or a ','
The default is no CC addresses.
@BCC (varchar(2048)) - Blind CC list separating each with a ';' or a ','
The default is no BCC addresses.
@SMTPServer (varchar(255)) - Network smtp server defaulted to your companies network
smtp server. Set this in the stored proc code.

sp_send_cdosysmail '<>', 'This is a test', @SMTPServer = <network smtp relay server>

The above example will send an smpt e-mail to <> from @@ServerName
with a subject of 'Message from SQL Server <@@ServerName>' and a
text body of 'This is a test' using the network smtp server specified.

Be sure to set the default for @SMTPServer before compiling this stored procedure.

Total article views: 1682 | Views in the last 30 days: 7
Related Articles

Results to File using | (Vertical bar) by default as a column separator

Results to File using | (Vertical bar) by default as a column separator





Separate Login for a query in a stored procedure

separate login for query


Separating Report Server

Using a separate server for external reporting


Changing the default port numbers when configuring database mirroring

There are times when you need to use different network ports to communicate between two servers runn...

sql server express    

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones