JRHeaven : Free Computer Books, IT Books, Project Guidelines, Novels and Many More...

Tuesday, September 29, 2015

Configure Database Mail in SQL Server to send e-mail from SQL Server Database


This article explains, How to configure Database Mail to send e-mail from SQL Server database. So, we explain this step by step as follows:

What is Database Mail ?

Database Mail is an enterprise solution for sending e-mail messages from the SQL Server Database Engine. Using Database Mailyour database applications can send e-mail messages to users. The messages can contain query results, and can also include files from any resource on your network.

STEP 1 : 


First of all, We need Microsoft SQL Server Management Studio (SSMS) installed on our system (PC or Laptop) to send mail from sql  server. So if you do not have installed SSMS on your system, then first download and install it from here.

STEP 2 : 
  1. Now Open SSMS and connect it to your SQL Server instance.
  2. Expand Management option, there you can find Database Mail option. As you can see in below image.

Monday, June 22, 2015

Create Windows Service to send mail daily using ASP.Net and C#


This article explains, How to create Windows Service in ASP.Net with C# to send mail on daily basis. So, we explain this step by step as following :


STEP 1 : 

Create Windows Service Proejct in Microsoft Visual Studio 2012 and give project name as   "WindowsServiceProject1".

STEP 2 : 

Now update your App.Config file as follow :
<configuration>
  <appSettings>
    <add key="StartTime" value="03:50 PM "/>
    <add key="callDuration" value="2"/>
    <add key="CallType" value="1"/>
    <add key="FromMail" value="your_from_email_id@gmail.com"/>
    <add key="Password" value="your_email_id_password"/>
    <add key="Host" value="smtp.gmail.com"/>
  </appSettings>
  <system.net>
    <mailSettings>
      <smtp from="your_from_email_id@gmail.com">
        <network host="smtp.gmail.com" userName="your_from_email_id@gmail.com" password="your_email_id_password" enableSsl="true" port="587" />
      </smtp>
    </mailSettings>
  </system.net>
</configuration>
In this configuration settings, we use gmail email id to send mail, so for that we use smtp.gmail.com as host and Port number 587.