MailAttachment
Attachment objects allow referencing files within a Email
object. Attachment objects are created using the MAIL New attachment
command.
Attachment Object
Attachment objects provide the following read-only properties and functions:
.cid : Text the ID of the attachment |
.disposition : Text the value of the Content-Disposition header |
.getContent() : 4D.Blob returns the contents of the attachment object in a 4D.Blob object |
.name : Text the name and extension of the attachment |
.path : Text the POSIX path of the attachment file, if it exists |
.platformPath : Text the path of the attachment file expressed with the current platform syntax |
.size : Integer the value of the size header of the attachment file |
.type : Text the content-type of the attachment file |
4D.MailAttachment.new()
History
Release | Changes |
---|---|
19 R2 | Accepts 4D.File, 4D.ZipFile, 4D.Blob |
4D.MailAttachment.new( file : 4D.File { ; name : Text {; cid : Text{ ; type : Text { ; disposition :Text } } } } ) : 4D.MailAttachment
4D.MailAttachment.new( zipFile : 4D.ZipFile { ; name : Text {; cid : Text{ ; type : Text { ; disposition :Text } } } } ) : 4D.MailAttachment
4D.MailAttachment.new( blob : 4D.Blob { ; name : Text {; cid : Text{ ; type : Text { ; disposition :Text } } } } ) : 4D.MailAttachment
4D.MailAttachment.new( path : Text { ; name : Text {; cid : Text{ ; type : Text { ; disposition :Text } } } } ) : 4D.MailAttachment
Parameter | Type | Description | |
---|---|---|---|
file | 4D.File | -> | Attachment file |
zipFile | 4D.ZipFile | -> | Attachment Zipfile |
blob | 4D.Blob | -> | BLOB containing the attachment |
path | Text | -> | Path of the attachment file |
name | Text | -> | Name + extension used by the mail client to designate the attachment |
cid | Text | -> | ID of attachment (HTML messages only), or " " if no cid is required |
type | Text | -> | Value of the content-type header |
disposition | Text | -> | Value of the content-disposition header: "inline" or "attachment". |
Result | 4D.MailAttachment | <- | Attachment object |
Description
The 4D.MailAttachment.new()
function creates and returns a new object of the 4D.MailAttachment
type. It is identical to the MAIL New attachment
command (shortcut).
.cid
.cid : Text
Description
The .cid
property contains the ID of the attachment. This property is used in HTML messages only. If this property is missing, the file is handled as a simple attachment (link).
.disposition
.disposition : Text
Description
The .disposition
property contains the value of the Content-Disposition
header. Two values are available:
- "inline": the attachment is rendered within the message contents, at the "cid" location. The rendering depends on the mail client.
- "attachment": the attachment is provided as a link in the message.
.getContent()
.getContent() : 4D.Blob
Parameter | Type | Description | |
---|---|---|---|
Result | 4D.Blob | <- | Content of the attachment |
Description
The .getContent()
function returns the contents of the attachment object in a 4D.Blob
object. You can use this method with attachment objects received by the MAIL Convert from MIME
command.
.name
.name : Text
Description
The .name
property contains the name and extension of the attachment. By default, it is the name of the file, unless another name was specified in the MAIL New attachment
command.
.path
.path : Text
Description
The .path
property contains the POSIX path of the attachment file, if it exists.
.platformPath
History
Release | Changes |
---|---|
19 | Added |
.platformPath : Text
Description
The .platformPath
property returns the path of the attachment file expressed with the current platform syntax.
.size
.size : Integer
Description
The .size
property contains the value of the size
header of the attachment file. The .size
property is returned when the MIME message defines a size header in the attachment part.
.type
.type : Text
Description
The .type
property contains the content-type
of the attachment file. If this type is not explicitly passed to the MAIL New attachment
command, the content-type
is based on its file extension.