AddPart (Email subroutine)

From m204wiki
Revision as of 21:00, 14 August 2012 by JAL2 (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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