OutputEmailDeviceProcessingScriptTemplate Field |
Default processing script template
Namespace: Seal.ModelAssembly: SealLibrary (in SealLibrary.dll) Version: 8.3.0.0+c4d725cbae26375217e6c77c92a07fffaea6377d
Syntaxpublic const string ProcessingScriptTemplate = "@using System.IO\r\n@{\r\n Report report = Model;\r\n ReportOutput output = report.OutputToExecute;\r\n var device = output.Device as OutputEmailDevice;\r\n\r\n if (string.IsNullOrEmpty(output.EmailTo)) throw new Exception("No email address has been specified in the report output.");\r\n var subject = Helper.IfNullOrEmpty(output.EmailSubject, report.ExecutionName);\r\n var sender = device.SenderEmail;\r\n if (device.ChangeSender && !string.IsNullOrEmpty(output.EmailFrom)) sender = output.EmailFrom;\r\n var replyTo = device.SenderEmail;\r\n if (device.ChangeSender && !string.IsNullOrEmpty(output.EmailReplyTo)) replyTo = output.EmailReplyTo;\r\n //Body\r\n var body = Helper.IfNullOrEmpty(output.EmailBody, report.Translate("Please find the report '{0}' in attachment.", report.ExecutionName));\r\n if (output.EmailHtmlBody && (output.Format == ReportFormat.html || output.Format == ReportFormat.print))\r\n {\r\n body = File.ReadAllText(report.ResultFilePath);\r\n }\r\n else if (output.EmailMessagesInBody || output.EmailSkipAttachments)\r\n {\r\n body = string.Format("Execution messages for report '{0}':\r\n\r\n{1}", report.FilePath, report.ExecutionMessages);\r\n }\r\n bool isHtmlBody = (output.EmailHtmlBody && (output.Format == ReportFormat.html || output.Format == ReportFormat.print));\r\n //Attachment\r\n string attachPath = "", attachName = "";\r\n if (!isHtmlBody && !output.EmailSkipAttachments)\r\n {\r\n device.HandleZipOptions(report);\r\n attachPath = report.ResultFilePath;\r\n attachName = Path.GetFileName(attachPath);\r\n if (output.Format == ReportFormat.html || output.Format == ReportFormat.print)\r\n {\r\n //Copy the file to avoid a lock\r\n attachPath = FileHelper.GetTempUniqueFileName(report.ResultFilePath);\r\n attachName = Path.GetFileNameWithoutExtension(report.ResultFileName) + Path.GetExtension(report.ResultFilePath);\r\n File.Copy(report.ResultFilePath, attachPath);\r\n }\r\n }\r\n\r\n device.SendEmail(sender, output.EmailTo, replyTo, output.EmailCC, output.EmailBCC, subject, isHtmlBody, body, attachPath, attachName);\r\n\r\n output.Information = report.Translate("Email sent to '{0}'", output.EmailTo.Replace("\r\n", "\n").Replace("\r", "\n").Replace("\n", ";"));\r\n report.LogMessage(output.Information); \r\n} \r\n"
Field Value
String
See Also