Sending email with specified export type and EmailExport.ShowDialog()

Tasos SavvaTasos Savva Cyprus
edited June 2018 in FastReport .NET
I have the following code
Config.ReportSettings.ShowProgress = false; 
FastReport.Export.Pdf.PDFExport pdf = new FastReport.Export.Pdf.PDFExport(); 
FastReport.Export.Email.EmailExport email = new FastReport.Export.Email.EmailExport(); 

email.Account.AllowUI = true; 
email.Account.Name = "CompanyName"; 

pdf.AllowModify = false; 
pdf.Compressed = true; 
pdf.EmbeddingFonts = false; 
pdf.Background = false; 
pdf.GradientQuality = FastReport.Export.Pdf.PDFExport.GradientQualityEnum.Low; 
pdf.JpegCompression = true; 
pdf.JpegQuality = 80; 
pdf.PrintOptimized = false; 
pdf.Name = "pdf"; 

email.Export = pdf; 
if (email.ShowDialog() == DialogResult.OK) 
       email.SendEmail(Report);

I've noticed after several tries that setting
email.Export = pdf
does not have any effect after calling
email.ShowDialog()

Does anyone knows how can I keep the settings that I pass to pdf as the default and let the user change them if needed?

Thanks

Comments

  • edited 1:22AM
    using (FastReport.Report report = new FastReport.Report())
    {
        report.Load("");
        report.RegisterData(dataSet);
        report.Prepare();
        using (FastReport.Export.Pdf.PDFExport pdf = new FastReport.Export.Pdf.PDFExport())
        {
            FastReport.Export.Email.EmailExport email = new FastReport.Export.Email.EmailExport();
            email.Account.AllowUI = true;
            email.Account.Address = "sender";
            email.Account.UserName = "";
            email.Account.Password = "";
            email.Account.EnableSSL = true;
            email.Account.Host = "smtp.gmail.com";
            email.Account.Port = 587;
            email.Subject = "";
            email.MessageBody = "";
            email.Address = "recipient";
            email.Export = pdf;
            if (email.ShowDialog() == DialogResult.OK)
                email.SendEmail(report);
        }
    }
    
  • Tasos SavvaTasos Savva Cyprus
    edited June 2018
    ipong wrote: »
    using (FastReport.Report report = new FastReport.Report())
    {
        report.Load("");
        report.RegisterData(dataSet);
        report.Prepare();
        using (FastReport.Export.Pdf.PDFExport pdf = new FastReport.Export.Pdf.PDFExport())
        {
            FastReport.Export.Email.EmailExport email = new FastReport.Export.Email.EmailExport();
            email.Account.AllowUI = true;
            email.Account.Address = "sender";
            email.Account.UserName = "";
            email.Account.Password = "";
            email.Account.EnableSSL = true;
            email.Account.Host = "smtp.gmail.com";
            email.Account.Port = 587;
            email.Subject = "";
            email.MessageBody = "";
            email.Address = "recipient";
            email.Export = pdf;
            if (email.ShowDialog() == DialogResult.OK)
                email.SendEmail(report);
        }
    }
    

    Hello, this will do the same thing, you have just rewrite the code using using.

    I need to set pdf properties before calling email.ShowDialog() and use those settings.
  • edited June 2018
    just copied my working code.
    then you have two options:
    1.upgrade to the latest version
    2.create your own code, export pdf to stream, email with System.Net.Mail library
  • Tasos SavvaTasos Savva Cyprus
    edited 1:22AM
    ipong wrote: »
    just copied my working code.
    then you have two options:
    1.upgrade to the latest version
    2.create your own code, export pdf to stream, email with System.Net.Mail library

    I have the latest version. Anyway, the solution came from Anatoly Kukuyuk.

    The solution is to show the PDF export settings window:
    pdf.ShowDialog();
    

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.