to send separate pdf file for each customer RRS feed

  • Question

  • Hi,

    Anybody can share an idea in C# how to implement the form bases c# program how to send email to customers as separate pdf using RDLC reportviewer. The rdlc report should not show up to the user. the pdf should be generated for each customer code in the datagridview. Any help would be very appreciate.

    If not possible in RDLCm is there any alternate solution.



    Thursday, April 7, 2016 7:50 AM

All replies

  • You can use the code below to send an email with attachment.

    using System.Net.Mail;
    namespace WindowsApplication1
        public partial class Form1 : Form
            public Form1()
            private void button1_Click(object sender, EventArgs e)
                    MailMessage mail = new MailMessage();
                    SmtpClient SmtpServer = new SmtpClient("");
                    mail.From = new MailAddress("");
                    mail.Subject = "Test Mail - 1";
                    mail.Body = "mail with attachment";
                    System.Net.Mail.Attachment attachment;
                    attachment = new System.Net.Mail.Attachment("your attachment file");
                    SmtpServer.Port = 587;
                    SmtpServer.Credentials = new System.Net.NetworkCredential("username", "password");
                    SmtpServer.EnableSsl = true;
                    MessageBox.Show("mail Send");
                catch (Exception ex)

    Put your emails in a List so you can loop through them.



    Thursday, April 7, 2016 8:09 AM
  • My question was actually meant  how can create multiple pdf file  dynamically, for each row on a datagridview . 

    Sorry for confusing you 



    Thursday, April 7, 2016 2:04 PM
  • To create pdf then you need the 3rd party library. I found a pdfsharp

    The code is quite straightforward.

    PdfDocument pdf = new PdfDocument();
                pdf.Info.Title = "My First PDF";
                PdfPage pdfPage = pdf.AddPage();
                XGraphics graph = XGraphics.FromPdfPage(pdfPage);
                XFont font = new XFont("Verdana", 20, XFontStyle.Bold);
                graph.DrawString("This is my first PDF document", font, XBrushes.Black, new XRect(0, 0, pdfPage.Width.Point, pdfPage.Height.Point), XStringFormats.Center);
                string pdfFilename = "firstpage.pdf";
     But depend on what is the document in your databridview you are pointing too. So you might need add additional coding.



    Thursday, April 7, 2016 11:49 PM
  • Hi Pol,

    >>If not possible in RDLCm is there any alternate solution.

    From above message, your case also more related to RDLC, I will help move your case to Report Viewer forum for better support.

    Best regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, April 11, 2016 9:11 AM