Share via


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.

To create a Database Mail configuration script by using templates

  1. On the View menu, select Template Explorer.

  2. In the Template Explorer window, expand the Database Mail folder.

  3. Double-click Simple Database Mail Configuration. The template opens in a new query window.

  4. On the Query menu, select Specify Values for Template Parameters. The Replace Template Parameters window opens.

  5. 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.

  6. 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)