How to: Create a Database Mail Configuration Script Using Templates (SQL Server Management Studio)
Database Mail Configuration Wizard provides a convenient way to configure Database Mail. You can also use the templates provided with Microsoft SQL Server Management Studio to quickly produce a Transact-SQL script that creates a Database Mail profile and an account for that profile. For more information about Database Mail Configuration Wizard, see Database Mail Configuration Wizard.
To create a Database Mail configuration script by using templates
On the View menu, select Template Explorer.
In the Template Explorer window, expand the Database Mail folder.
Double-click Simple Database Mail Configuration. The template opens in a new query window.
On the Query menu, select Specify Values for Template Parameters. The Replace Template Parameters window opens.
Type values for the profile_name, account_name, SMTP_servername, email_address, and display_name. SQL Server Management Studio fills in the template with the values you provide.
Execute the script to create the configuration.
Note
The script does not grant any database users access to the profile. Therefore, by default, the profile can only be used by members of the sysadmin fixed security role. For more information about granting access to profiles, see sysmail_add_principalprofile_sp (Transact-SQL)
See Also
Tasks
How to: Create Database Mail Public Profiles (Transact-SQL)
How to: Create Database Mail Private Profiles (Transact-SQL)
How to: Create Database Mail Accounts (Transact-SQL)
Concepts
Other Resources
Database Mail Configuration Wizard
sysmail_add_principalprofile_sp (Transact-SQL)