AddPart (Email subroutine): Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
 
(2 intermediate revisions by the same user not shown)
Line 3: Line 3:
==Syntax==
==Syntax==
{{Template:Email:AddPart syntax}}
{{Template:Email:AddPart syntax}}
===Syntax terms===
===Syntax terms===
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%email</th>
<tr><th>email</th>
<td>A previously declared Email object.
<td>An <var>Email</var> object.</td></tr>
</td></tr>
 
<tr><th>content</th>
<tr><th>content</th>
<td>A Stringlist or longstring that contains the attachment or body part.
<td>A <var>Stringlist</var> or <var>Longstring</var> that contains the attachment or body part.
   
   
If a Stringlist is passed, each item in the Stringlist is delimited
If a <var>Stringlist</var> is passed, each item in the <var>Stringlist</var> is delimited
with a carriage-return/line-feed (CR/LF) character pair.
with a carriage-return/line-feed (CR/LF) character pair.
To override this line-ending, you can specify a non-text content type
To override this line-ending, you can specify a non-text content type
as the value of the <code>type</code> optional argument, described below.
as the value of the <var>Type</var> optional argument, described below.
In this case, no delimiter is added at the end of an item.
In this case, no delimiter is added at the end of an item.
   
   
If a longstring is passed, no delimiters are added to the content.
If a longstring is passed, no delimiters are added to the content.</td></tr>
</td></tr>
 
<tr><th>options</th>
<tr><th><var>Type</var></th>
<td>Any comma-separated combination of the following options.
<td>This [[Notation conventions for methods#Named parameters|name required]] parameter is a string that specifies the MIME type of the content. MIME content-type strings consist of a primary type and a subtype delimited by a forward slash ( / ) character, for example, <code>text/xml</code>.
Each may be specified only once.
<p>
<dl>
<var>AddPart</var> performs no validity checking, but it does distinguish
<dt>Type
between text MIME types ("text" is the primary type) and non-text types.
<dd>This [[Notation conventions for methods#Name required parameters|name required]] parameter is a string
If non-text, <var>AddPart</var> encodes the content in base64 format to ensure correct translation at SMTP gateways.
that specifies the MIME type of the content.
You can override this encoding by specifying the <var>Encoding</var> option set to the value <var>None</var>. </p></td></tr>
MIME content type strings consist
 
of a primary type and a subtype delimited by a forward slash ( / ) character,
<tr><th><var>Encoding</var></th>
for example, <code>text/xml</code>.
<td>This [[Notation conventions for methods#Name required parameters|name required]] parameter is a string that forces or suppresses encoding for the attachment.
AddPart performs no validity checking, but it does distinguish
between text MIME types (&amp;ldquo;text&amp;rdquo; is the primary type) and non-text types.
If non-text, AddPart encodes the content in base64 format
to ensure correct translation at SMTP gateways.
You can override this encoding by specifying
the <var>Encoding</var> option set to the value <code>none</code>.
<dt>Encoding
<dd>This [[Notation conventions for methods#Name required parameters|name required]] parameter is a string
that forces or suppresses encoding for the attachment.
Since base64 encoding is automatically enabled for any non-text content,
Since base64 encoding is automatically enabled for any non-text content,
the <var>Encoding</var> option is usually unnecessary.
the <var>Encoding</var> option is usually unnecessary.
Line 47: Line 38:
not recommended: the likely result is that the recipient receives corrupt data,
not recommended: the likely result is that the recipient receives corrupt data,
or otherwise the SMTP gateway may simply discard the message.
or otherwise the SMTP gateway may simply discard the message.
<dt>Name
 
<dd>This name required parameter is a string that
<tr><th><var>Name</var></th>
provides a name for the attachment.
<td>This name required parameter is a string that provides a name for the attachment. The name is used when saving the attachment to a file.
The name is used when saving the attachment to a file.
 
<dt>Disposition
<tr><th><var>Disposition</var></th>
<dd>This name required parameter, available as of <var class="product">Sirius Mods</var> version 7.6,
<td>This name required parameter, available as of <var class="product">Sirius Mods</var> version 7.6, provides a content-disposition header for the attachment. If you do not specify a disposition value, no content-disposition header is provided for the attachment.
provides a content-disposition header for the attachment.
If you do not specify a disposition value, no content-disposition header
is provided for the attachment.
The method does no validity checking for the
content-disposition, so you can specify whatever disposition you want.
<dt>Description
<dd>This name required parameter, available as of <var class="product">Sirius Mods</var> version 7.6,
is a string that provides a content-description header for the attachment.
If you do not specify a description value, no content-description header
is provided for the attachment.
</dl>
</td></tr></table>
   
   
The method does no validity checking for the content-disposition, so you can specify whatever disposition you want.
<tr><th><var>Description</var></th>
<td>This name required parameter, available as of <var class="product">Sirius Mods</var> version 7.6, is a string that provides a content-description header for the attachment. If you do not specify a description value, no content-description header is provided for the attachment.</td></tr>
</table>
==Usage notes==
==Usage notes==
<ul>
<ul>
<li>Subsequent invocations of the <var>AddPart</var> method add a separate attachment
<li>Subsequent invocations of the <var>AddPart</var> method add a separate attachment
to the existing content.
to the existing content.
<li>For a code example that includes the addition of an attachment,
<li>For a code example that includes the addition of an attachment,
see [[SMTP Helper#E-mail with attachment|"E-mail with attachment"]].
see [[Email class#E-mail with attachment|"E-mail with attachment"]].
</ul>
</ul>
==See also==
==See also==
{{Template:Email:AddPart footer}}
{{Template:Email:AddPart footer}}

Latest revision as of 21:00, 14 August 2012

Add one or more attachments (Email class)


Syntax

email:AddPart( content, [Type= string], [Name= string], [Encoding= string], - [Disposition= string], [Description= string])

Syntax terms

email An Email object.
content A Stringlist or Longstring that contains the attachment or body part.

If a Stringlist is passed, each item in the Stringlist is delimited with a carriage-return/line-feed (CR/LF) character pair. To override this line-ending, you can specify a non-text content type as the value of the Type optional argument, described below. In this case, no delimiter is added at the end of an item.

If a longstring is passed, no delimiters are added to the content.
Type This name required parameter is a string that specifies the MIME type of the content. MIME content-type strings consist of a primary type and a subtype delimited by a forward slash ( / ) character, for example, text/xml.

AddPart performs no validity checking, but it does distinguish between text MIME types ("text" is the primary type) and non-text types. If non-text, AddPart encodes the content in base64 format to ensure correct translation at SMTP gateways. You can override this encoding by specifying the Encoding option set to the value None.

Encoding This name required parameter is a string that forces or suppresses encoding for the attachment.

Since base64 encoding is automatically enabled for any non-text content, the Encoding option is usually unnecessary. To enable base64 encoding for text content, specify encoding=base64. To disable encoding for non-text content, specify encoding=none.

Specifying encoding=none for non-text content is not recommended: the likely result is that the recipient receives corrupt data, or otherwise the SMTP gateway may simply discard the message.

Name This name required parameter is a string that provides a name for the attachment. The name is used when saving the attachment to a file.
Disposition This name required parameter, available as of Sirius Mods version 7.6, provides a content-disposition header for the attachment. If you do not specify a disposition value, no content-disposition header is provided for the attachment.

The method does no validity checking for the content-disposition, so you can specify whatever disposition you want.

Description This name required parameter, available as of Sirius Mods version 7.6, is a string that provides a content-description header for the attachment. If you do not specify a description value, no content-description header is provided for the attachment.

Usage notes

  • Subsequent invocations of the AddPart method add a separate attachment to the existing content.
  • For a code example that includes the addition of an attachment, see "E-mail with attachment".

See also