In this article, we will show you the step by step approach to Configure SQL Server Database Mail to send Emails using your Gmail account, or any other account. In order to configure it, Please select the Management Folder within the SQL Server Object explorer, and then select Database Mail.
Right click on the Database Mail will open the context menu. Please select the Configure Database Mail option to configure the new database Mail, or to View, Edit, Delete existing Database Mails.
Once you select the Configure Database Mail option, a new wizard will be opened as we shown below.
Configure SQL Server Database Mail
Select configuration Task: This page is used to create, or Manage Database Mails. In this example we want to configure new database mail so, please select the Set up Database Mail by performing the following tasks option
New Profile: This page to create a new profile, and to add the SMTP account. From the below screenshot you can see that, we assigned Email as the profile name, and This is an Email Configuration as the profile description. Next, click on the Add button to add new SMTP account to this profile.
Once you click on the Add button, a new window called New Database Mail Account will pop up.
- Account Name: A unique name for this SMTP account.
- Description: Valid description for the above specified account
- Email Address: Email Id that you want to use for sending an Email. Senders Email Address.
- Display Name: This name is displayed within the sent mail.
- Reply Email: same as Email Address
- Server Name: valid SMTP name. If you are using Gmail then use smtp.gmail.com, and for Windows live account use smtp.live.com etc
- Port Number: By default you can use Port number 25, but for Gmail SSL, please use 587.
Next, under the SMTP Authentication section, you have to specify the Authentication details.
- Windows Authentication: It will use the Windows credentials
- Basic Authentication: Always use this option. Here please specify the senders Email ID, password.
- Anonymous Authentication: It will not use any authentication
From the below screenshot you can see that, we assigned MSBI as the account name, This is a Gmail Account as description, and Suresh as the display name.
After you click OK, SMTP account creation form will be closed
If it is your default profile then select Yes otherwise, please leave the option to default No.
Click Next button
Click on the Finish button to finish Configure SQL Server Database Mail to send emails.
Lastly, it will display the details. Please click on the Close button to close the wizard.
Now right-click on the Database Mail will open the context Menu. this time, Please select Send Test E-Mail.. option to send Email using the SMTP account that we created earlier.
Add the to address, Change Subject, and Message Body as per your requirements. And after you complete editing, Please click the Send Test E-Mail button to send an Email.
Let me open My Gmail account
Delete SQL Server Database Mail
In order to delete the configured database Email, Right click on the Database Mail will open the context menu. Please select the Configure Database Mail option to open the wizard. And in the second Page, please select the Manage Database Mail accounts and profiles option this time.
Manage Profiles and Accounts: Use this page to create, View, Edit, or delete the accounts and profiles.
- Create a new account: This option is used to create a new account.
- View, Change, or Delete an existing account: As its name suggest, we can View, edit or delete existing accounts.
- Create a new profile: Use this option to create a new profile.
- View, Change, or Delete an existing profile: As its name suggest, we can View, edit or delete existing profiles.
Before you start deleting the Account, you have to delete the profiles that are linked to that account so, we are selecting the last option to delete the profile.
From the drop down list, please select the Profile Name and click Delete button to delete the profile.
After deleting the profile, please select the second option to delete the account
Or you can use the following SQL Query to delete the account
EXECUTE msdb.dbo.sysmail_delete_account_sp @account_name = 'MSBI' ;
Thank You for Visiting Our Blog