Click or drag to resize

OutputEmailDeviceProcessingScriptTemplate Field

Default processing script template

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

Field Value

String
See Also