SendMailTask 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
发送一封电子邮件。 此类不能被继承。
public ref class SendMailTask sealed : Microsoft::SqlServer::Dts::Runtime::Task, Microsoft::SqlServer::Dts::Runtime::IDTSBreakpointSite, Microsoft::SqlServer::Dts::Runtime::IDTSComponentPersist, Microsoft::SqlServer::Dts::Tasks::SendMailTask::IDTSSendMailTask
[Microsoft.SqlServer.Dts.Runtime.DtsTask(HelpKeyword="sql13.dts.designer.sendmailtask.F1", LocalizationType=typeof(Microsoft.SqlServer.Dts.Tasks.SendMailTask.SendMailTaskMessages), SamplesTag="SsisSendMailTask", TaskContact="Send Mail Task; Microsoft Corporation; SQL Server 2016; © 2015 Microsoft Corporation; All Rights Reserved;http://www.microsoft.com/sql/support/default.asp;1", TaskType="DTS90", UITypeName="Microsoft.SqlServer.Dts.Tasks.SendMailTask.SendMailTaskUI, Microsoft.SqlServer.SendMailTaskUI, Version=13.0.0.0, Culture=Neutral, PublicKeyToken=89845dcd8080cc91")]
public sealed class SendMailTask : Microsoft.SqlServer.Dts.Runtime.Task, Microsoft.SqlServer.Dts.Runtime.IDTSBreakpointSite, Microsoft.SqlServer.Dts.Runtime.IDTSComponentPersist, Microsoft.SqlServer.Dts.Tasks.SendMailTask.IDTSSendMailTask
[Microsoft.SqlServer.Dts.Runtime.DtsTask(HelpKeyword="sql13.dts.designer.sendmailtask.F1", LocalizationType=typeof(Microsoft.SqlServer.Dts.Tasks.SendMailTask.SendMailTaskMessages), SamplesTag="SsisSendMailTask", TaskContact="Send Mail Task; Microsoft Corporation; SQL Server 2017; © 2017 Microsoft Corporation; All Rights Reserved;http://www.microsoft.com/sql/support/default.asp;1", TaskType="DTS90", UITypeName="Microsoft.SqlServer.Dts.Tasks.SendMailTask.SendMailTaskUI, Microsoft.SqlServer.SendMailTaskUI, Version=14.0.0.0, Culture=Neutral, PublicKeyToken=89845dcd8080cc91")]
public sealed class SendMailTask : Microsoft.SqlServer.Dts.Runtime.Task, Microsoft.SqlServer.Dts.Runtime.IDTSBreakpointSite, Microsoft.SqlServer.Dts.Runtime.IDTSComponentPersist, Microsoft.SqlServer.Dts.Tasks.SendMailTask.IDTSSendMailTask
[Microsoft.SqlServer.Dts.Runtime.DtsTask(HelpKeyword="sql13.dts.designer.sendmailtask.F1", LocalizationType=typeof(Microsoft.SqlServer.Dts.Tasks.SendMailTask.SendMailTaskMessages), SamplesTag="SsisSendMailTask", TaskContact="Send Mail Task; Microsoft Corporation; SQL Server 2019; © 2019 Microsoft Corporation; All Rights Reserved;http://www.microsoft.com/sql/support/default.asp;1", TaskType="DTS90", UITypeName="Microsoft.SqlServer.Dts.Tasks.SendMailTask.SendMailTaskUI, Microsoft.SqlServer.SendMailTaskUI, Version=15.0.0.0, Culture=Neutral, PublicKeyToken=89845dcd8080cc91")]
public sealed class SendMailTask : Microsoft.SqlServer.Dts.Runtime.Task, Microsoft.SqlServer.Dts.Runtime.IDTSBreakpointSite, Microsoft.SqlServer.Dts.Runtime.IDTSComponentPersist, Microsoft.SqlServer.Dts.Tasks.SendMailTask.IDTSSendMailTask
[<Microsoft.SqlServer.Dts.Runtime.DtsTask(HelpKeyword="sql13.dts.designer.sendmailtask.F1", LocalizationType=typeof(Microsoft.SqlServer.Dts.Tasks.SendMailTask.SendMailTaskMessages), SamplesTag="SsisSendMailTask", TaskContact="Send Mail Task; Microsoft Corporation; SQL Server 2016; © 2015 Microsoft Corporation; All Rights Reserved;http://www.microsoft.com/sql/support/default.asp;1", TaskType="DTS90", UITypeName="Microsoft.SqlServer.Dts.Tasks.SendMailTask.SendMailTaskUI, Microsoft.SqlServer.SendMailTaskUI, Version=13.0.0.0, Culture=Neutral, PublicKeyToken=89845dcd8080cc91")>]
type SendMailTask = class
inherit Task
interface IDTSComponentPersist
interface IDTSSendMailTask
interface IDTSBreakpointSite
interface IDTSSuspend
[<Microsoft.SqlServer.Dts.Runtime.DtsTask(HelpKeyword="sql13.dts.designer.sendmailtask.F1", LocalizationType=typeof(Microsoft.SqlServer.Dts.Tasks.SendMailTask.SendMailTaskMessages), SamplesTag="SsisSendMailTask", TaskContact="Send Mail Task; Microsoft Corporation; SQL Server 2017; © 2017 Microsoft Corporation; All Rights Reserved;http://www.microsoft.com/sql/support/default.asp;1", TaskType="DTS90", UITypeName="Microsoft.SqlServer.Dts.Tasks.SendMailTask.SendMailTaskUI, Microsoft.SqlServer.SendMailTaskUI, Version=14.0.0.0, Culture=Neutral, PublicKeyToken=89845dcd8080cc91")>]
type SendMailTask = class
inherit Task
interface IDTSComponentPersist
interface IDTSSendMailTask
interface IDTSBreakpointSite
interface IDTSSuspend
[<Microsoft.SqlServer.Dts.Runtime.DtsTask(HelpKeyword="sql13.dts.designer.sendmailtask.F1", LocalizationType=typeof(Microsoft.SqlServer.Dts.Tasks.SendMailTask.SendMailTaskMessages), SamplesTag="SsisSendMailTask", TaskContact="Send Mail Task; Microsoft Corporation; SQL Server 2019; © 2019 Microsoft Corporation; All Rights Reserved;http://www.microsoft.com/sql/support/default.asp;1", TaskType="DTS90", UITypeName="Microsoft.SqlServer.Dts.Tasks.SendMailTask.SendMailTaskUI, Microsoft.SqlServer.SendMailTaskUI, Version=15.0.0.0, Culture=Neutral, PublicKeyToken=89845dcd8080cc91")>]
type SendMailTask = class
inherit Task
interface IDTSComponentPersist
interface IDTSSendMailTask
interface IDTSBreakpointSite
interface IDTSSuspend
Public NotInheritable Class SendMailTask
Inherits Task
Implements IDTSBreakpointSite, IDTSComponentPersist, IDTSSendMailTask
- 继承
- 属性
- 实现
示例
下面的代码示例创建、配置和执行一个新 SendMailTask代码。
using Microsoft.SqlServer.Dts.Runtime;
using Microsoft.SqlServer.Dts.Tasks.SendMailTask;
class TestSendMailTask
{
public static void Main()
{
Package pkg = new Package();
ConnectionManager smtpCM;
smtpCM = pkg.Connections.Add("SMTP");
smtpCM.Name = "SMTP Connection Manager";
smtpCM.ConnectionString = "smtphost";
Executable exe = pkg.Executables.Add("STOCK:SendMailTask");
TaskHost thSendMailTask = (TaskHost)exe;
{
thSendMailTask.Properties["SmtpConnection"].SetValue(thSendMailTask, "SMTP Connection Manager");
thSendMailTask.Properties["ToLine"].SetValue(thSendMailTask, "someone1@example.com");
thSendMailTask.Properties["CCLine"].SetValue(thSendMailTask, "someone2@example.com");
thSendMailTask.Properties["BCCLine"].SetValue(thSendMailTask, "someone3@example.com");
thSendMailTask.Properties["FromLine"].SetValue(thSendMailTask, "someone4@example.com");
thSendMailTask.Properties["Priority"].SetValue(thSendMailTask, MailPriority.Normal);
thSendMailTask.Properties["FileAttachments"].SetValue(thSendMailTask, "C:\\test_image.jpg");
thSendMailTask.Properties["Subject"].SetValue(thSendMailTask, "Testing the SendMail Task");
thSendMailTask.Properties["MessageSourceType"].SetValue(thSendMailTask, SendMailMessageSourceType.DirectInput);
thSendMailTask.Properties["MessageSource"].SetValue(thSendMailTask, "This is only a test.");
}
DTSExecResult valResults = pkg.Validate(pkg.Connections, pkg.Variables, null, null);
if (valResults == DTSExecResult.Success)
{
pkg.Execute();
}
}
}
Imports Microsoft.SqlServer.Dts.Runtime
Imports Microsoft.SqlServer.Dts.Tasks.SendMailTask
Module TestSendMailTask
Sub Main()
Dim pkg As New Package
Dim smtpCM As ConnectionManager
smtpCM = pkg.Connections.Add("SMTP")
smtpCM.Name = "SMTP Connection Manager"
smtpCM.ConnectionString = "smtphost"
Dim exe As Executable = pkg.Executables.Add("STOCK:SendMailTask")
Dim thSendMailTask As TaskHost = CType(exe, TaskHost)
With thSendMailTask
.Properties("SmtpConnection").SetValue(thSendMailTask, "SMTP Connection Manager")
.Properties("ToLine").SetValue(thSendMailTask, "someone1@example.com")
.Properties("CCLine").SetValue(thSendMailTask, "someone2@example.com")
.Properties("BCCLine").SetValue(thSendMailTask, "someone3@example.com")
.Properties("FromLine").SetValue(thSendMailTask, "someone4@example.com")
.Properties("Priority").SetValue(thSendMailTask, MailPriority.Normal)
.Properties("FileAttachments").SetValue(thSendMailTask, "C:\test_image.jpg")
.Properties("Subject").SetValue(thSendMailTask, "Testing the SendMail Task")
.Properties("MessageSourceType").SetValue(thSendMailTask, SendMailMessageSourceType.DirectInput)
.Properties("MessageSource").SetValue(thSendMailTask, "This is only a test.")
End With
Dim valResults As DTSExecResult = pkg.Validate(pkg.Connections, pkg.Variables, Nothing, Nothing)
If valResults = DTSExecResult.Success Then
pkg.Execute()
End If
End Sub
End Module
注解
通过使用“发送邮件”任务,当包工作流中的任务成功或失败时,包可以发送通知消息。 有关详细信息,请参阅 “发送邮件任务”。
构造函数
SendMailTask() |
初始化 SendMailTask 类的新实例。 |
属性
BCCLine |
获取或设置密件抄送邮件收件人的电子邮件地址,在有多个收件人时以分号分隔。 |
CCLine |
获取或设置抄送邮件收件人的电子邮件地址,在有多个收件人时以分号分隔。 |
DebugMode |
获取或设置一个布尔值,该值指示对象是否处于调试模式,以及它是否应在运行时引发 OnBreakpointHit(IDTSBreakpointSite, BreakpointTarget) 事件。 |
ExecutionValue |
返回用户定义对象。 此字段为只读。 (继承自 Task) |
FileAttachments |
获取或设置附加到电子邮件的文件的名称,在有多个文件时用竖线字符 (|) 分隔。 |
FromLine |
获取或设置发件人的电子邮件地址。 |
MessageSource |
获取或设置邮件正文或者包含邮件正文的源的名称。 |
MessageSourceType |
获取或设置包含邮件正文的源类型的值。 |
Priority |
获取或设置邮件的优先级。 |
SmtpConnection |
获取或设置简单邮件传输协议 (SMTP) 服务器的名称或 IP 地址。 |
Subject |
获取或设置电子邮件的主题。 |
SuspendRequired |
获取或设置一个布尔值,该值指示任务在遇到断点时是否应挂起。 遇到断点时,将由任务和容器的运行时引擎设置此值。 |
TargetServerVersion |
发送一封电子邮件。 此类不能被继承。 (继承自 Task) |
ToLine |
获取或设置获取或设置收件人的电子邮件地址,在有多个收件人时以分号分隔。 |
Version |
*** 不推荐使用的成员;请参阅“备注”。 *** 返回任务的版本。 此属性为只读。 (继承自 Task) |