ASP.NET Chart Management (EMail submission with integrated graphical reference image)

I am using an asp.net chart control and I am happy with that. My client now asks me if I can add an email button to my web page to send an email with the chart included in it. Any ideas how I can do this? Thanks.

+3
source share
3 answers

The chart component actually generates an image when the chart is requested. Then it either saves this image in the file system, or simply holds it in memory. This part is customizable.

You can create a diagram, and then take a link to the file from it. From there you have two choices. Either your email address refers to the file using a link to the URL, or embeds it in the actual email address. This is also configured by the mail client.

+2
source

You can save the image somewhere and upload it and paste it into the mail as follows:

        private void SendMail()
        {
            //Your mail body is created with help of a StringBuilder which will contain the img tag:
            //Suppose the mailContent is the StringBuilder object and has the html body etc already appended....
            //you would need to append something like following:

            //mailContent.Append("<td><img src=\"cid:IMAGE_ID\"></td>");
            //string body = mailContent.ToString();


            string smtpServer = "mailhost.my.domain.net";
            string emailFrom = "blah.blah@blah.com";
            string emailTo = "yoyo@yoyo.com";


            MailMessage msg = new MailMessage(emailFrom, emailTo, "TestMail...", body);

            msg.IsBodyHtml = true;

            //Adding attachments by loading from file 
            Attachment item = new Attachment("Images/Logo.JPG");
            item.ContentDisposition.Inline = true;
            item.ContentDisposition.DispositionType = DispositionTypeNames.Inline;
            item.ContentId = "IMAGE_ID";
            item.ContentType.MediaType = "image/jpeg";
            item.ContentType.Name = "Logo.JPG";

            msg.Attachments.Add(item);

            SmtpClient client = new SmtpClient(smtpServer);
            client.Send(msg);

        }
+2
source

, , HTML-, , . HTML-, , .

0

Source: https://habr.com/ru/post/1708442/


All Articles