0
我放置了一個腳本任務,其中包含將電子郵件On Error
發送到Event Handler
的代碼。現在我需要附加或發送輸出或錯誤日誌與消息。如何將輸出或錯誤附加到SSIS事件處理程序中的電子郵件腳本
我已經搜索並找不到明確的解決方案。
注意:郵件驗證是一個包含驗證信息的類。
電子郵件代碼:
[Microsoft.SqlServer.Dts.Tasks.ScriptTask.
SSISScriptTaskEntryPointAttribute]
public partial class ScriptMain : Microsoft.SqlServer.Dts.
Tasks.ScriptTask.VSTARTScriptObjectModelBase
{
public static string EmailBody()
{
StringBuilder userMessage = new StringBuilder();
userMessage.Append("Mail Body Text");
userMessage.Append("Mail Body Text");
userMessage.Append("\n\nMail Body Text");
userMessage.Append("\nMail Body Text");
userMessage.Append("\nMail Body Text");
return userMessage.ToString();
}
public void Main()
{
var fromAddress = new MailAddress(MailAuthentication.mailFrom, "From Me");
var toAddress = new MailAddress(MailAuthentication.mailTo, "To Someone");
const string fromPassword = MailAuthentication.password;
const string subject = "Who Shot the couch";
string body = EmailBody().ToString();
var smtp = new SmtpClient
{
Host = MailAuthentication.liveSMTP,
Port = 587,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
Credentials = new NetworkCredential(fromAddress.Address, fromPassword),
Timeout = 20000
};
using (var message = new MailMessage(fromAddress, toAddress)
{
Subject = subject,
Body = body
})
{
smtp.Send(message);
}
}
enum ScriptResults
{
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
};
}