FastReport.Report report = new FastReport.Report();
FilePath filePath = @"C:\Test.frx";
Bitmap bitmap = FormLetter::companyLogo(); //从表中获取图片文件
Bindata bindata = new Bindata();
System.Byte[] picByte;
FastReport.Export.Email.EmailExport email = new FastReport.Export.Email.EmailExport();
FastReport.Export.Email.EmailSettings emailSettings = new FastReport.Export.Email.EmailSettings();
FastReport.Export.Pdf.PDFExport pdf = new FastReport.Export.Pdf.PDFExport(); //pdf文档
FastReport.Export.Html.HTMLExport html = new FastReport.Export.Html.HTMLExport();
FastReport.Export.OoXML.Word2007Export word = new FastReport.Export.OoXML.Word2007Export(); //导出WORD文档
str ccStr = "1111@qq.com,2222@163.com,33333@163.com";
System.String[] cc = System.Text.RegularExpressions.Regex::Split(ccStr,","); //字符串分解为字符串数组
;
if (bitmap)
{
bindata.setData(bitmap);
picByte = System.Convert::FromBase64String(binData.base64Encode()); //类型转换
}
report.Load(filePath);
report.SetParameterValue("CompanyLogo",picByte); //fastReport传参,图片
report.SetParameterValue("JournalId","Test Report");
report.Prepare();
emailSettings.set_Address("xxx"); //邮件帐号
emailSettings.set_EnableSSL(true);
emailSettings.set_Host("smtp.exmail.qq.com");
emailSettings.set_Password("pwd");
emailSettings.set_UserName("xxx");
email.set_Account(emailSettings);
email.set_Address("xxxx"); //收件人,fastReport发送邮件时,收件人只能设一个,抄送人可以设多个
email.set_CC(cc);
email.set_Subject("test");
email.set_MessageBody("This is a test job");
pdf.SetReport(report);
email.set_Export(pdf);
// report.Show();
email.SendEmail(report);
info("ok");