.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> C# >> Post New QuestionBookmark and Share Subscribe to Forum

How to retrieve data from sql table and send mail in html form?

Posted By: Pravin     Posted Date: August 05, 2011    Points:5   Category :C#
For example:
There is a table in sql called 'Member.dbo' with fields of
Name,
Designation,
Department,
Industry,Country,
city,
ContactNo,
EmailID.

In these fields i need to get values of Name, Designation, Department,EmailID into HTML body and send them to mail.

If anyone know the code in C#, post it.




Responses
Author: Zinnia             
Posted Date: August 08, 2011     Points: 20   

Hi Pravin, First of all u retrieve the required data from sql table. Then use:
System.Text.StringBuilder obj=new System.Text.StringBuilder();
obj.Append("<table><tr><td>");
obj.Append("Dear "+dr["Name"].ToString());

Please use the required fields in the above mentioned ways. Then initialise the obj in a string variable as shown below.
obj.Append("</td></tr></table>");
string body=obj.ToString();

Now U can send this body in mail. For sending mail, there r lots of link available. U can have a look on the following link also.
http://www.dotnetfunda.com/articles/article995-bulk-email-sending-through-gmail-.aspx


Zinnia Sarkar
http://sarkarzinnia.blogspot.com
Author: Pravin             
Posted Date: August 08, 2011     Points: 20   

Hi Zinna ,

Thanks for ur post,
I think this will help me.



Pravin



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend