SendMailTask.FileAttachments 속성

정의

전자 메일 메시지에 첨부된 파일의 이름(파일이 둘 이상인 경우 파이프 문자(|)로 구분)을 가져오거나 설정합니다.

public:
 property System::String ^ FileAttachments { System::String ^ get(); void set(System::String ^ value); };
public string FileAttachments { get; set; }
member this.FileAttachments : string with get, set
Public Property FileAttachments As String

속성 값

전자 메일 메시지에 첨부된 파일의 이름을 포함하는 문자열입니다.

구현

예제

다음 코드 샘플에서는 속성을 사용하는 FileAttachmentsSendMailTask 코드를 만들고 구성하고 실행합니다.

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  

설명

속성에 파일 이름을 FileAttachments 지정하여 작업을 만들 때 파일의 정적 복사본을 첨부하거나, 대신 런타임에 동적으로 업데이트된 파일을 보내는 변수, 구성 또는 속성 식을 사용하여 파일의 위치를 가리킬 수 있습니다. 이 기능은 로그 및 예외 파일과 같은 첨부 파일을 보내는 데 유용합니다. 파일 이름을 파이프 문자(|)로 구분하여 작업에 여러 첨부 파일을 포함할 수 있습니다.

참고

패키지를 실행할 때 첨부 파일 파일이 없으면 패키지에서 오류 메시지가 발생합니다.

적용 대상