SendMailTask.FileAttachments プロパティ

電子メール メッセージに添付されたファイルの名前を取得します。値の設定も可能です。ファイルが複数ある場合はパイプ文字 (|) で区切られます。

名前空間:  Microsoft.SqlServer.Dts.Tasks.SendMailTask
アセンブリ:  Microsoft.SqlServer.SendMailTask (Microsoft.SqlServer.SendMailTask.dll)

構文

'宣言
Public Property FileAttachments As String 
    Get 
    Set
'使用
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)

プロパティ値

型: System.String
電子メール メッセージに添付されたファイルの名前を表す String です。

実装

IDTSSendMailTask.FileAttachments

説明

FileAttachments プロパティでファイル名を指定してタスクを作成するときにファイルの静的コピーを添付するか、変数、構成またはプロパティ式を使用してファイルの場所を指定し、実行時に動的に更新されたファイルを送信することができます。 この機能は、ログ ファイルや例外ファイルなどの添付ファイルを送信するときに便利です。 パイプ文字 (|) でファイル名を区切ることでタスクに複数の添付ファイルを含めることができます。

注意

パッケージが実行されるときに添付ファイルが存在しないと、パッケージでエラー メッセージが発生します。

使用例

次のコード サンプルでは、FileAttachments プロパティを使用する新しい SendMailTask を作成し、構成して実行します。

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

関連項目

参照

SendMailTask クラス

Microsoft.SqlServer.Dts.Tasks.SendMailTask 名前空間