Click here to Skip to main content
15,889,992 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to Send Gridview data in outlook Email Body in Asp.Net Using C#....

This code is send to mail in asp.net C# to outlook....

utlook.Application oApp = new outlook.Application();

outlook.MailItem oMsg = (outlook.MailItem)oApp.CreateItem(outlook.OlItemType.olMailItem);
outlook.Inspector oInspector = oMsg.GetInspector;
oMsg.HTMLBody = "Dear Sir,
Here how to bind gridview value..!!
";

oMsg.Subject = "New Request from Scaffolding Jobs";
outlook.Recipients oRecips = (outlook.Recipients)oMsg.Recipients;
outlook.Recipient oRecip = (outlook.Recipient)oRecips.Add("Safihur@fabtech.ae");

oRecip.Resolve();
oMsg.Send();
oRecip = null;
oRecips = null;
oMsg = null;
oApp = null;
Posted
Updated 6-Jun-14 23:57pm
v2

 
Share this answer
 
v2
Comments
safihur Rahuman 7-Jun-14 6:02am    
this is not related to our question
Nayan Rudani 7-Jun-14 6:08am    
Are you sending Gridview Data To single Email body ?
safihur Rahuman 7-Jun-14 6:14am    
yes boss
Nayan Rudani 7-Jun-14 6:30am    
then Add below Code
Msg.Body += "Please check below data <br/><br/>";
Msg.Body += GetGridviewData(gvUserInfo);

and Function
public string GetGridviewData(GridView gv)
{
StringBuilder strBuilder = new StringBuilder();
StringWriter strWriter = new StringWriter(strBuilder);
HtmlTextWriter htw = new HtmlTextWriter(strWriter);
gv.RenderControl(htw);
return strBuilder.ToString();
}

Here gvUserInfo is Gridview
safihur Rahuman 7-Jun-14 7:08am    
gv.RenderControl(htw); this line occur error:
Error Message is : An exception of type 'System.InvalidOperationException' occurred in System.Web.dll but was not handled in user code

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900