Thursday, May 16, 2013

How to send database mail using SQL server 2012

Here am showing how send database mail using SQLSERVER 2012
The first step is to enable database mail.Here am showing how to use gmail smtp server for sending mails using sqlserver database mail profile.

How to enable database mail :

To enable database mail you need to set the "Database Mail XPs" option to 1.

Below code will enable the database mail.

sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'Database Mail XPs', 1;
GO
RECONFIGURE
GO

Execute the above code. this will enable the database mail.
























after enable the database mail profile.

Go to Management-->Database Mail

Select Configure Database Mail.








select setup database mail by performing the following tasks as below.







Click on next 






















Click on Add
























Click on new Account.Account name mall profile i already created before showing this demo.























Provide Account name : any thing meaningful name

Description : Description of account name

Email Address : Specify your gmail address  for sending mail

Server name : Smtp.gmail.com .This is the smtp server for sending mails.

Port number : 25 (default port number).But you use other gmail smtp  port number also

In order send db mail you must check the Check box this requires a secure connection.(SSL)

Select basic authentication.

Provide your gmail credentials. copy and paste will not work properly. I suggest to type the password in both fields.(password,confirm password).

Click on Ok























Click on next




You can use public or private . Public profile can be accessed by all database users for sending mails.

.Also you use the default profile as 'Yes' or 'No'.

Click on next 























Click on finish





































No comments: