22.1Class Part

Part of a MIME document.

Class Part( [headers],[body] )
headers The headers of this part.
body The body of this part.

About the formats of the headers and body parameters, see respectively the Part.headers and Part.body properties.

Properties
bodyBody of the part.
headersDictionary of headers.
str
Methods
addPartAdds a part to this MIME part.
attachDataAttach a data content to the mail part.
attachFileAttach a given file.
attachPartAttach a ready-made part content to the mail part.
makeBoundary
removePartRemoves a previously added part
setMessageSets this part to be a Message part
setMultipartDeclares that this will be a part holding more parts.

Properties

body

Body of the part.

The body represents the part payoff. The body should be simply the untranslated content you want to send to the remote part; the carrier will eventually fiddle with the encoding to make it compatible with the final stream.

headers

Dictionary of headers.

This dictionary holds headers in the form

In the second form, the main parameter is always indicated by the "" (empty string) key, while the sub-parameters are expressed as list of strings.

The parameters will be escaped during output.

str

Methods

addPart

Adds a part to this MIME part.

addPart( part )
part the Part to be added.
Returnself

The part must have been previously set as multipart via Part.setMessage or Part.setMultipart.

attachData

Attach a data content to the mail part.

attachData( data, type, fname, [partName] )
data A string or memory buffer with the data to be attached.
type Content/type of the data
fname The file name of the part element.
partName Logical name of the part in the Mime document,
ReturnThe new part created by this method.

This method creates an attachment for this MIME Part suitable to hold binary data.

If this part had already a content but wasn't a multi-part element, then the content is moved in a new multipart element that is prepended to the part to be added.

The part created by this method can be configured afterwards.

attachFile

Attach a given file.

attachFile( fullPath, type, [partName] )
fullPath the path to the file.
type the MIME type for the attached file.
partName Logical name of the part in the final document.

attachPart

Attach a ready-made part content to the mail part.

attachPart( part )
part The part to be added.
Returnself

This is similar to AddPart, but in case this parent part is not a multipart element, it is turned into a "multipart/mixed" element and its former contents are moved in a separate part, which is prepended to the parameter.

makeBoundary

makeBoundary( count )

removePart

Removes a previously added part

removePart( part )
part The part to be removed.
Returntrue If the part was found (and removed), false otherwise

setMessage

Sets this part to be a Message part

setMessage( [id],[partNo],[partCount] )
id If given, this is a message/partial part, where the whole message has the given ID.
partNo If the message is "partial", then this indicates the number of the part.
partCount If the message is "partial", then this indicates the count of all the parts.
Returnself

If id is not given, the part will be considered a "message/RFC822" multipart message.

When id is given, partNo is mandatory, while partCount is optional (even if it's strongly suggested to add it if possible).

setMultipart

Declares that this will be a part holding more parts.

setMultipart( [partMode],[boundary] )
partMode Mode of this multipart (defaults to "mixed")
boundary If there is an already defined boundary for this part.

Setting a MIME element as multi-part has important semantic consequences. A mime-part with sub-parts will receive an automatic content-type and boundary,

The body, if present, becomes a "preamble", and is to be generally ignored.

The content type becomes "multipart", with a subtype that declares the semantic mode. The partMode parameter is used to declare the subtype, and may be one of the Multipart enumeration, or a string (in which case it's used directly).

Made with http://www.falconpl.org