How to create mail profile in sql server 2012

In SQL Server 2012, a mail profile is used to configure the settings for sending and receiving emails using the SQL Server Database Mail feature. Here are the steps to create a mail profile:

Step 1: Create a Database Mail Account

  1. Open SQL Server Management Studio (SSMS) and connect to your SQL Server instance.
  2. In the Object Explorer, expand the "SQL Server" node, then right-click on "Database Mail" and select "Configure Database Mail".
  3. In the "Database Mail Configuration" window, click on the "Add" button to create a new mail account.
  4. Fill in the required information, such as the account name, email address, and password.
  5. Click "OK" to create the mail account.

Step 2: Create a Mail Profile

  1. In the Object Explorer, expand the "SQL Server" node, then right-click on "Database Mail" and select "Configure Database Mail".
  2. In the "Database Mail Configuration" window, click on the "Add" button to create a new mail profile.
  3. Fill in the required information, such as the profile name, description, and the mail account you created in Step 1.
  4. Click "OK" to create the mail profile.

Step 3: Configure the Mail Profile

  1. In the Object Explorer, expand the "SQL Server" node, then expand the "Database Mail" node, and then right-click on the mail profile you created and select "Properties".
  2. In the "Database Mail Profile Properties" window, you can configure various settings, such as:
    • The mail server and port
    • The authentication method (e.g., username and password, Windows authentication)
    • The email format (e.g., plain text, HTML)
    • The default sender email address
  3. Click "OK" to save the changes.

Step 4: Test the Mail Profile

  1. To test the mail profile, you can use the following T-SQL command:
    EXEC msdb.dbo.sp_send_dbmail @profile_name = 'Your Mail Profile Name', 
                              @recipients = '[email protected]', 
                              @subject = 'Test Email', 
                              @body = 'This is a test email.'

    Replace "Your Mail Profile Name" with the name of the mail profile you created, and "[email protected]" with the email address of the recipient.

That's it! You have now created a mail profile in SQL Server 2012. You can use this profile to send emails from your SQL Server instance.