Compartilhar via


Propriedade do RDL FileAttachments

Gets or sets the names of the files attached to the e-mail message, delimited by the pipe character (|) when there is more than one file.

Namespace:  Microsoft.SqlServer.Dts.Tasks.SendMailTask
Assembly:  Microsoft.SqlServer.SendMailTask (em Microsoft.SqlServer.SendMailTask.dll)

Sintaxe

'Declaração
Public Property FileAttachments As String
    Get
    Set
'Uso
Dim instance As SendMailTask
Dim value As String

value = instance.FileAttachments

instance.FileAttachments = value
public string FileAttachments { get; set; }
public:
virtual property String^ FileAttachments {
    String^ get () sealed;
    void set (String^ value) sealed;
}
abstract FileAttachments : string with get, set
override FileAttachments : string with get, set
final function get FileAttachments () : String
final function set FileAttachments (value : String)

Valor da propriedade

Tipo: System. . :: . .String
A String containing the names of the files attached to the e-mail message.

Implementa

IDTSSendMailTask. . :: . .FileAttachments

Comentários

You can either attach a static copy of a file when you create the task by specifying the file name in the FileAttachments property, or you can point to the location of a file by using a variable, a configuration, or a property expression to send a dynamically updated file at run time instead. This feature is useful for sending attachments such as log and exception files. You can include multiple attachments in a task by separating the file names with the pipe character (|).

ObservaçãoObservação

If an attachment file does not exist when the package runs, the package raises an error message.

Exemplos

The following code sample creates, configures, and executes a new SendMailTask that uses the FileAttachments property.

Imports Microsoft.SqlServer.Dts.Runtime
Imports Microsoft.SqlServer.Dts.Tasks.SendMailTask

Module Module1

  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
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