Cloud Application Integration (On-Premises) : Integration Server Built-In Services : MIME Folder : pub.mime:addBodyPart
pub.mime:addBodyPart
WmPublic. Adds a body part (header fields and content) to a specified MIME object.
Input Parameters
mimeData
Document MIME object to which you want to add a body part. (This IData object is produced by pub.mime:createMimeData.)
content
java.io.InputStream or Object Content that you want to add to the MIME object. content can be an InputStream or another MIME object. Use an InputStream to add an ordinary payload. Use a MIME object to add a payload that is itself a MIME message.
isEnvStream
String Flag that specifies whether content is to be treated as a MIME entity.
Important:  
This parameter is only used if content is an InputStream.
Set this parameter to one of the following values:
*yes to treat content as a MIME entity. addBodyPart will strip out the header fields from the top of content and add them to mimeData as part headers. The remaining data will be treated as the payload.
Note:  
addBodyPart assumes that all data up to the first blank line represents the entity's header fields.
*no to treat content as an ordinary payload.
mimeHeader
Document Specifies the part headers that you want to add with this body part. Key names represent the names of the header fields. The values of the keys represent the values of the header fields.
For example, if you wanted to add the following header fields:
X-Doctype: RFQ
X-Severity: 10
You would set mimeHeader as follows:
Key
Value
X-Doctype
RFQ
X-Severity
10
Be aware that the following MIME headers are automatically inserted by pub.mime:getEnvelopeStream when it generates the MIME message:
Message-ID
MIME-Version
Additionally, you use the content, encoding, and description parameters to set the following fields:
Content-Type
Content-Transfer-Encoding
Content-Description
If you set these header fields in mimeHeader and you create a single-part message, the values in contenttype, encoding, and description, if specified, will override those in mimeHeader. See usage notes.
contenttype
String Optional. The value of the Content-Type header for this body part. For single-part messages, this value overrides the Content-Type value in mimeHeader, if one is present. Defaults to text/plain.
See usage notes.
encoding
String Optional. Specifies how the body part is to be encoded for transport and sets the value of the Content-Transfer-Encoding header. For single-part messages, this value overrides the Content-Transfer-Encoding value in mimeHeader, if one is present. Defaults to 7bit.
See usage notes.
Note:  
This parameter determines how the payload is to be encoded for transport. When you add a payload to mimeData, it should be in its original format. The pub.mime:getEnvelopeStream service will perform the encoding (as specified by encoding) when it generates the final MIME message.
Set to:
*7bit to specify that content is 7-bit, line-oriented text that needs no encoding. This is the default.
*8bit to specify that content is 8-bit, line-oriented text that needs no encoding.
Note:  
This encoding value is not recommended for messages that will be transported via SMTP over the Internet, because the data can be altered by intervening mail servers that can't accommodate 8-bit text. To safely transport 8-bit text, use quoted-printable encoding instead.
*binary to specify that content contains binary information that needs no encoding.
Note:  
This encoding value is not recommended for messages that will be transported via SMTP over the Internet, because the data can be altered by intervening mail servers that can't accommodate binary data. To safely transport binary data, use base64 encoding instead.
*quoted-printable to specify that content contains 7 or 8-bit, line-oriented text that you want to encode using the quoted-printable encoding scheme.
*base64 to specify that content contains an arbitrary sequence of octets that you want to encode using the base64 encoding scheme.
*uuencode to specify that content contains an arbitrary sequence of octets that you want to encode using the uuencode encoding scheme.
description
String Optional. Specifies the value of the Content-Description header for this body part.
multipart
String Optional. Flag that determines how addBodyPart behaves if mimeData already contains one or more body parts.
By default, addBodyPart simply appends a new body part to mimeData if it already contains a payload. (This allows you to construct multi-part messages.) However, you can override this behavior if you want to either replace the existing payload with the new body part or throw an exception under these circumstances (see replace parameter, below).
Set to:
*yes to append a new body part to mimeData. This is the default.
*no to replace the existing payload with the new body part. (Depending on the value of replace, this setting may cause addBodyPart to throw an exception.)
replace
String Optional. Flag that specifies whether addBodyPart replaces the existing payload or throws an exception when it receives a mimeData that already contains a payload. This parameter is only used when multipart is set to no.
Set to:
*yes to replace the existing payload with the new body part. This is the default.
*no to throw an exception.
Output Parameters
mimeData
Document MIME object to which the body part was added.
Usage Notes
This service operates on the MIME object (mimeData) produced by pub.mime:createMimeData.
The way in which the contenttype and encoding parameters are applied depends on whether the finished message is single-part or multipart.
For single-part messages:
*contenttype specifies the Content-Type for the entire MIME message. It overrides any value assigned to the Content-Type header in mimeHeader. If Content-Type is not specified in contenttype or mimeHeader, the value of the Content-Type header defaults to text/plain.
*encoding specifies the Content-Transfer-Encoding for the entire MIME message. It overrides any value assigned to the Content-Transfer-Encoding header in mimeHeader. If Content-Transfer-Encoding is not specified in encoding or mimeHeader, the value of the Content-Transfer-Encoding header defaults to 7bit.
For multipart messages:
*contenttype specifies the Content-Type for an individual body part. The Content-Type for the entire MIME message is automatically set to multipart/mixed, or to multipart/subType if a subtype was specified when the MIME object was created. See pub.mime:createMimeData.
*encoding specifies the Content-Transfer-Encoding for an individual body part. The Content-Transfer-Encoding header in mimeHeader, if present, specifies the encoding for the entire MIME message. If Content-Transfer-Encoding is not specified in mimeHeader, or if the specified value is not valid for a multipart message, the value of the Content-Transfer-Encoding header defaults to 7bit. (7bit, 8bit, and binary are the only encoding values valid for multipart messages.)
For general information about MIME messages and using the MIME services, see the MIME-S/MIME Developer’s Guide.
See Also
pub.mime:createMimeData
pub.mime:getBodyPartContent
pub.mime:addMimeHeader
Examples
For examples of how to use this service, see the following services in the certified samples area of the Knowledge Center on the Empower Product Support Website https://empower.softwareag.com.
samples.mime:build_SimpleMIME
samples.mime:build_MultipartMIME
Copyright © 2015- 2016 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback