Sending Multiple emails using Mail Merge and SMTP using ASP.NET and C#


In the source code, fill in the proper connection string of your database. After doing so, write the query in the source code that will generate at least a column comprising of the email addresses of the recipients. So now, the DataGrid will be having the contents of the result of the query that has been fired as well as a check box against each tuple.

 

The checkbox against the recipients (to whom the email is to be sent) is checked.

 

Also, for the email body, the desired information pertinent to a particular recipient can be included along in the mail, by enclosing the column name in the merge tags "%". The mail is written in the text box that appears below the DataGrid.

 

For example:

 

Say the DataGrid contains the following column names (as a result of your query)

 

1. UserName

 

2. MachineName

 

3. EmailID

 

4. BirthDate

The following figure shows the output window:


Figure 1.

 

So the email can be written as:

 

Dear %UserName%,

Your computer name is %MachineName%. And your birthdate is %BirthDate%.

Regards,

Team

After the 'Send' button is clicked, the emails are sent to the users (against whom the check mark appears) with the merge tags being replaced with the relevant information.

Up Next
    Ebook Download
    View all
    Learn
    View all