displaying a chart and a datagrid in one email ( .net C#)

Unanswered displaying a chart and a datagrid in one email ( .net C#)

  • Tuesday, September 11, 2012 7:12 PM
     
      Has Code

    I have a report that consists of a gridview based on a query, and a chart item based on a different query. I am NOt able to display them both in the same email. I am seeing an X like the image doesnt exist. But the chart image does get created in the location/path specified

    Code is as follows

    MailMessage m = new MailMessage(); 
                SmtpClient smtp = new SmtpClient("smtpservername", 25); 
                m.From = new System.Net.Mail.MailAddress("vananthraman@abcd.com"); 
                m.To.Add("vananthraman@abcd.com"); 
                m.Subject = "This is a test"; 
     
                AlternateView plainView = AlternateView.CreateAlternateViewFromString("This is my plain text content, viewable by those clients that don't support html", null, "text/plain"); 
     
                AlternateView htmlView = AlternateView.CreateAlternateViewFromString("<img src=cid:companylogo>", null, "text/html"); 
     
     
     
                System.Net.Mail.LinkedResource logo = new System.Net.Mail.LinkedResource(path); 
                logo.ContentId = "companylogo"; 
     
                htmlView.LinkedResources.Add(logo); 
     
                m.AlternateViews.Add(plainView); 
                m.AlternateViews.Add(htmlView); 
     
     
     
                //some_query is defined here 
                        using (SqlCommand cmd = new SqlCommand(some_query, connection)) 
                        { 
     
     
                            GridView gvwBmonitor = new GridView(); 
                            SqlDataReader reader = cmd.ExecuteReader(); 
                            gvwBmonitor.DataSource = reader; 
                            gvwBmonitor.DataBind(); 
     
     
                            m.IsBodyHtml = true; 
                            StringBuilder sb = new StringBuilder(); 
                            HtmlTextWriter hw = new HtmlTextWriter(new StringWriter(sb)); 
                            gvwBookingmonitor.RenderControl(hw); 
     
                            m.Body = m.Body + sb.ToString(); 
                            AlternateView htmlView2 = AlternateView.CreateAlternateViewFromString(sb.ToString(), null, "text/html"); 
                            m.AlternateViews.Add(htmlView2); 
                            smtp.Send(m); 
     
                        } 
    

    I ONLY SEE THE CHART AND NOT THE GRID ..how can I fix this???