SendMailTask.MessageSource Property


Gets or sets the message body or the name of the source that contains the message body.

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

public string MessageSource { get; set; }

Property Value

Type: System.String

A String containing the message text or the name of the source that contains the message.

The type of message source is specified by the MessageSourceType property.

The following code sample creates, configures, and executes a new SendMailTask that uses the MessageSource 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, "")
      .Properties("CCLine").SetValue(thSendMailTask, "")
      .Properties("BCCLine").SetValue(thSendMailTask, "")
      .Properties("FromLine").SetValue(thSendMailTask, "")
      .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
    End If

  End Sub

End Module
Return to top