TestPlan SendEmail
Document

SendEmail

by Group Public on Tuesday April 14 2009 @ 16:49:29 (1/1 Points)

API ↪Reference ✑ Reply ✓ Stick It ✗ Ditch It ⚐ Tag It

SendEmail can be used to send an email to a target. It allows sending very basic emails, or complex emails with multiple parts and attachments.

Basic Email

The most basic email can be sent as follows.

SendEmail with
  %To% someobdy@domain.com
  %From% me@here.com
  %Subject% the body of the message
  %Body% the text of the message
end

Multipart

A simple text and html form of the same email is seen in this example.

SendEmail with
  %To% someobdy@domain.com
  %From% me@here.com
  %Subject% the body of the message
  %Parts% withvector
    with
      %Content-Type% text/html
      %Body% <h1>Hello</h1>
    end

    with
      %Content-Type% text/plain
      %Body% == Hello ==
    end
  end

Options

Each part, or high-level, specification has several optional parameters.

ContentType and Charset

These are both reflected in the same header field in the resulting email. However note that ContentType is simply applied as a label and will not result in any modification of the data.

Charset however will alter the data, in that the provided Body will be sent encoded in the specified character set.

Headers

Headers can be specified as an additional map in the case where you need additional or custom headers.

%Headers% with
    %X-SOAPAction% FuncA
    %CC% happy@user.com
  end
Note that the CC header here will be added to the message but the message will not be sent to this address.

File vs. Body

Instead of a Body parameter File can be specified and the binary contents of that file will be sent.

%File% %This:Dir%/image.png
  %ContentType% image/png

If you wish to use the textual contents of the file you can use the Body parameter and the textFile function.

%Body% as textFile %This:Dir%/myfile.txt

Configuration

By default localhost will be used to send emails. If you require a different SMTP agent to send emails you can alter the Email.SMTP.Host and Email.SMTP.Port context items.

© 2008-2010 edA-qa mort-ora-y
Using Persephone and TestPlan
Tag: