MailTask Class

Summary

Sends an SMTP message.
Assembly
NAnt.Core.dll
Namespace
NAnt.Core.Tasks
Interfaces
Base Types
graph BT Type-->Base0["Task"] click Base0 "/api/NAnt.Core/Task" Base0-->Base1["Element"] click Base1 "/api/NAnt.Core/Element" Base1-->Base2["Object"] Type-.->Interface0["IConditional"] click Interface0 "/api/NAnt.Core/IConditional" Type["MailTask"] class Type type-node

Syntax

[TaskName("mail")]
public class MailTask : Task, IConditional

Examples

Sends an email from nant@sourceforge.net to three recipients with a subject about the attachments. The body of the message will be the combined contents of all .txt files in the base directory. All zip files in the base directory will be included as attachments. The message will be sent using the smtpserver.anywhere.com SMTP server.

    <mail 
    from="nant@sourceforge.net" 
    tolist="recipient1@sourceforge.net" 
    cclist="recipient2@sourceforge.net" 
    bcclist="recipient3@sourceforge.net" 
    subject="Msg 7: With attachments" 
    mailhost="smtpserver.anywhere.com">
    <files>
        <include name="*.txt" />
    </files>   
    <attachments>
        <include name="*.zip" />
    </attachments>
</mail>

Sends an email from a gmail account to multiple recipients. This example illustrates how to add a recipient's name to an email address.

<mail
from="+xxxx+@gmail.com"
tolist="(Rep A) recipient1@sourceforge.net;(Rep B) recipient2@sourceforge.net"
subject="Sample Email"
mailhost="smtp.gmail.com"
mailport="465"
ssl="true"
user="+xxxx+@gmail.com"
password="p@ssw0rd!"
message="Email from NAnt" />

Email addresses in any of the lists (to, cc, bcc, from) can be in one of the five listed formats below.

  • Full Name <address@abcxyz.com>
  • <address@abcxyz.com> Full Name
  • (Full Name) address@abcxyz.com
  • address@abcxyz.com (Full Name)
  • address@abcxyz.com

Remember to use &gt; and &lt; XML entities for the angle brackets.

Remarks

Text and text files to include in the message body may be specified as well as binary attachments.

Attributes

Type Description
TaskNameAttribute Indicates that class should be treated as a task.

Properties

Name Value Summary
Attachments FileSet
Attachments that are transmitted with the message.
BccList string
Semicolon-separated list of BCC: recipient email addresses.
CcList string
Semicolon-separated list of CC: recipient email addresses.
CustomXmlProcessing bool
Gets a value indicating whether the element is performing additional processing using the NAnt.Core.Element.XmlNode that was used to initialize the element.
Inherited from Element
EnableSsl bool
Indicates whether or not ssl should be used to connect to the smtp host.
FailOnError bool
Determines if task failure stops the build, or is just reported. The default is true.
Inherited from Task
Files FileSet
Files that are transmitted as part of the body of the email message.
Format MailTask.MailFormat
Format of the message. The default is NAnt.Core.Tasks.MailTask.MailFormat.Text.
From string
Email address of sender.
IfDefined bool
If true then the task will be executed; otherwise, skipped. The default is true.
Inherited from Task
IsBodyHtml bool
Indicates whether or not the body of the email is in html format. The default value is false.
Location Location
Gets or sets the location in the build file where the element is defined.
Inherited from Element
LogPrefix string
The prefix used when sending messages to the log.
Inherited from Task
Mailhost string
Host name of mail server. The default is localhost.
Message string
Text to send in body of email message.
Name string
The name of the task.
Inherited from Task
NamespaceManager XmlNamespaceManager
Gets or sets the System.Xml.XmlNamespaceManager.
Inherited from Element
Parent Object
Gets or sets the parent of the element.
Inherited from Element
Password string
The password to use when connecting to the smtp host.
Port int
The port number used to connect to the mail server. The default is 25.
Project Project
Gets or sets the NAnt.Core.Element.Project to which this element belongs.
Inherited from Element
Properties PropertyDictionary
Gets the properties local to this NAnt.Core.Element and the NAnt.Core.Element.Project.
Inherited from Element
ReplyTo string
Reply to email address.
Subject string
Text to send in subject line of email message.
Threshold Level
Gets or sets the log threshold for this NAnt.Core.Task. By default the threshold of a task is NAnt.Core.Level.Debug, causing no messages to be filtered in the task itself.
Inherited from Task
ToList string
Semicolon-separated list of recipient email addresses.
UnlessDefined bool
Opposite of NAnt.Core.Task.IfDefined. If false then the task will be executed; otherwise, skipped. The default is false.
Inherited from Task
UserName string
The username to use when connecting to the smtp host.
Verbose bool
Determines whether the task should report detailed build log messages. The default is false.
Inherited from Task
XmlNode XmlNode
Gets or sets the XML node of the element.
Inherited from Element

Methods

Name Value Summary
CopyTo(Element) void
Copies all instance data of the NAnt.Core.Element to a given NAnt.Core.Element.
Inherited from Element
Execute() void
Executes the task unless it is skipped.
Inherited from Task
ExecuteTask() void
This is where the work is done.
GetAttributeConfigurationNode(FrameworkInfo, string) XmlNode
Locates the XML node for the specified attribute in either the configuration section of the extension assembly or the.project.
Inherited from Task
GetAttributeConfigurationNode(XmlNode, FrameworkInfo, string) XmlNode
Inherited from Element
GetLocation() Location
Retrieves the location in the build file where the element is defined.
Inherited from Element
Initialize() void
Initializes task and ensures the supplied attributes are valid.
Initialize(XmlNode) void
Performs default initialization.
Inherited from Element
InitializeBuildElement(Element, XmlNode, Element, Type) Element
Initializes the build element.
Inherited from Element
static
InitializeElement(XmlNode) void
Derived classes should override to this method to provide extra initialization and validation not covered by the base class.
Inherited from Element
InitializeTask(XmlNode) void
Initializes the task.
Inherited from Task
InitializeTaskConfiguration() void
Initializes the configuration of the task using configuration settings retrieved from the NAnt configuration file.
Inherited from Task
InitializeXml(XmlNode, PropertyDictionary, FrameworkInfo) void
Initializes all build attributes and child elements.
Inherited from Element
IsLogEnabledFor(Level) bool
Determines whether build output is enabled for the given NAnt.Core.Level.
Inherited from Task
Log(Level, string) void
Logs a message with the given priority.
Inherited from Task
Log(Level, string, Object[]) void
Logs a formatted message with the given priority.
Inherited from Task