Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET ADO.NET
HI all!!!
 
I want to send data from a dataset through email to the customer. Please tell me how to do it.
 
I have done this much so far
 
    private void databind()
    {
        int id = Convert.ToInt32(Request.Cookies["Ship"]["OrderID"].ToString());
        con.Open();
        SqlCommand cmd= new SqlCommand("Select a.OID,a.PID,a.OPQuantity,a.PPrice,a.OPTotalPrice ,b.PName, (a.OPQuantity * (b.PTax/100 *a.PPrice)) as Tax from OrderProducts a,Products b where a.OID='" + id + "' and a.PID=b.PID", con);
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        da.Fill(ds);
        GridView1.DataSource = ds;
        GridView1.DataBind();
        SqlDataReader dr = cmd.ExecuteReader();
        DataTable tb = new DataTable();
        tb.Load(dr);
      
        con.Close();
    }
 
What should i do after this step ?? I mean how to send the data from this datatable through email
 
I have done the mail sending part . I only need to know how to send this data
Posted 7-May-12 21:42pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

You can render the gridview in HTML and send it as email body
StringBuilder sb = new StringBuilder(); 
StringWriter sw = new StringWriter(sb);
HtmlTextWriter hw = new HtmlTextWriter(sw); 
GridView1.RenderControl(hw);
 
sb.ToString() will be included in email body
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I only need to know how to send this data
Email text goes in 'Body' property.
 
Now, you need to define how or what all you want to send in an email. Sending a datatable does not make any sense. You have to format the data in some readable/understandable format.
 
Add a text around it with value form datatable. Form the complete string and then pass it on to body of email.
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 399
1 Nirav Prabtani 338
2 Abhinav S 170
3 PIEBALDconsult 160
4 Dave Kreskowiak 155
0 OriginalGriff 7,580
1 Sergey Alexandrovich Kryukov 6,806
2 Maciej Los 3,919
3 Peter Leow 3,693
4 CHill60 2,742


Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 10 May 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100