Export (0) Print
Expand All

SendMailMessageSourceType Enumeration

Specifies the type of the MessageSource property, which contains or points to the body of the e-mail message.

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

public enum SendMailMessageSourceType

Member nameDescription
DirectInputSpecifies that the message source is contained as text in the MessageSource property.
FileConnectionSpecifies that the message source is contained in the file named in the MessageSource property.
VariableSpecifies that the message source is contained in the variable named in the MessageSource property.

The following code sample creates a new SendMailTask that uses the SendMailMessageSourceType enumeration.

using Microsoft.SqlServer.Dts.Runtime;
using Microsoft.SqlServer.Dts.Tasks.SendMailTask;

class Program
{
  static void Main(string[] args)
  {
    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();
    }
  }
}

Community Additions

ADD
Show:
© 2014 Microsoft