Creating, sending or receiving emails in 4D is done by handling an Email
object. This object is used by the following commands and methods:
- SMTP -
.send()
function to send an email through SMTP - POP3 -
.getMail()
function to get an email from a POP3 server - IMAP -
.getMail()
and.getMails()
functions to get emails from an IMAP server. MAIL Convert from MIME
andMAIL Convert to MIME
commands to convert emails
Email オブジェクト
Email objects provide the following properties:
4D follows the JMAP specification to format the Email object.
.attachments : Collection attachment オブジェクトのコレクション |
.bcc : Text .bcc : Object .bcc : Collection 非表示 (BCC: Blind Carbon Copy) のメール受信者 アドレス |
.bodyStructure : Object (任意) メッセージ本文の完全なMIME ストラクチャーである EmailBodyPart オブジェクト |
.bodyValues : Object (任意) |
.cc : Text .cc : Object .cc : Collection 追加 (CC: Carbon Copy) のメール受信者 アドレス |
.comments : Text 追加のコメントのヘッダー |
.from : Text .from : Object .from : Collection メールの送信元 アドレス |
.headers : Collection メッセージ内で現れる順番どおりの |
.htmlBody : Text (任意、SMTPのみ) HTML形式のメールメッセージ (デフォルトの文字セットは UTF-8) |
.id : Text IMAP サーバーからの固有ID |
.inReplyTo : Text カレントメッセージが返信している、元のメッセージのメッセージID |
.keywords : Object 各プロパティ名がキーワードであり、各値が true であるキーワードセットのオブジェクト |
.messageId : Text メッセージ識別ヘッダー ("message-id") |
.receivedAt : Text IMAPサーバーにメールが到着した時間の、ISO 8601 UTC フォーマットでのタイムスタンプ (例: 2020-09-13T16:11:53Z) |
.references : Collection 返信チェーン内メッセージの、全メッセージID のコレクション |
.replyTo : Text .replyTo : Object .replyTo : Collection 返信用 アドレス |
.sendAt : Text メールのタイムスタンプ (ISO 8601 UTCフォーマット) |
.sender : Text .sender : Object .sender : Collection メールのソース アドレス |
.size : Integer IMAPサーバーから返された Email オブジェクトのサイズ (バイト単位) |
.subject : Text メールの件名 |
.textBody : Text (任意、SMTPのみ) 標準テキスト形式のメールメッセージ (デフォルトの文字セットは UTF-8) |
.to : Text .to : Object .to : Collection メールのメインの受信者 アドレス |
Email Addresses
All properties that contain email addresses (from
, cc
, bcc
, to
, sender
, replyTo
) accept a value of text, object, or collection type.
テキスト
- single email: "somebody@domain.com"
- single display name+email: "Somebody somebody@domain.com"
- several emails: "Somebody somebody@domain.com,me@home.org"
オブジェクト
An object with two properties:
プロパティ | タイプ | 説明 |
---|---|---|
name | テキスト | Display name (can be null) |
テキスト | Email address |
コレクション
A collection of address objects.
Handling body part
The textBody
and htmlBody
properties are only used with the SMTP.send() function to allow sending simple mails. When both property are filled, the MIME content-type multipart/alternative is used. The email client should then recognize the multipart/alternative part and display the text part or html part as necessary.
bodyStructure
and bodyValues
are used for SMTP when the Email object is built from a MIME document, e.g. when generated by the MAIL Convert from MIME
command. In this case, both bodyStructure
and bodyValues
properties must be passed together, and it is not recommended to use textBody
and htmlBody
.
Example of bodyStructure and bodyValues objects
"bodyStructure": {
"type": "multipart/mixed",
"subParts": [
{
"partId": "p0001",
"type": "text/plain"
},
{
"partId": "p0002",
"type": "text/html"
}
]
},
"bodyValues": {
"p0001": {
"value": "I have the most brilliant plan. Let me tell you all about it."
},
"p0002": {
"value": "<!DOCTYPE html><html><head><title></title><style type=\"text/css\">div{font-size:16px}</style></head><body><div>I have the most brilliant plan. Let me tell you all about it.</div></body></html>"
}
}
.attachments
.attachments : Collection
説明
.attachments
プロパティは、 attachment オブジェクトのコレクションを格納します。
Attachment objects are defined through the MAIL New attachment
command.
.bcc
.bcc : Text
.bcc : Object
.bcc : Collection
説明
.bcc
プロパティは、 非表示 (BCC: Blind Carbon Copy) のメール受信者 アドレスを格納します。
.bodyStructure
.bodyStructure : Object
説明
.bodyStructure
プロパティは、 (任意) メッセージ本文の完全なMIME ストラクチャーである EmailBodyPart オブジェクトを格納します。 See Handling body part section.
.bodyStructure
オブジェクトには、次のプロパティが格納されています:
プロパティ | タイプ | 結果 |
---|---|---|
partID | テキスト | Identifies the part uniquely within the email |
type | テキスト | (mandatory) Value of the Content-Type header field of the part |
charset | テキスト | Value of the charset parameter of the Content-Type header field |
encoding | テキスト | If isEncodingProblem=true , the Content-Transfer-Encoding value is added (by default undefined) |
disposition | テキスト | Value of the Content-Disposition header field of the part |
language | Collection of texts | List of language tags, as defined in RFC3282, in the Content-Language header field of the part, if present. |
location | テキスト | URI, as defined in RFC2557, in the Content-Location header field of the part, if present. |
subParts | Collection of objects | Body parts of each child (collection of EmailBodyPart objects) |
headers | Collection of objects | List of all header fields in the part, in the order they appear in the message (collection of EmailHeader objects, see headers property) |
.bodyValues
.bodyValues : Object
説明
.bodyValues
プロパティは、 (任意) bodyStructure
の <partID> 毎にオブジェクトを格納している EmailBodyValue オブジェクトを格納します。 See Handling body part section.
.bodyValues
オブジェクトには、次のプロパティが格納されています:
プロパティ | タイプ | 結果 |
---|---|---|
partID.value | text | Value of the body part |
partID.isEncodingProblem | boolean | True if malformed sections are found while decoding the charset, or unknown charset, or unknown content transfer-encoding. False by default |
.cc
.cc : Text
.cc : Object
.cc : Collection
説明
.cc
プロパティは、 追加 (CC: Carbon Copy) のメール受信者 アドレスを格納します。
.comments
.comments : Text
説明
.comments
プロパティは、 追加のコメントのヘッダーを格納します。
Comments only appear within the header section of the message (keeping the message's body untouched).
For specific formatting requirements, please consult the RFC#5322.
.from
.from : Text
.from : Object
.from : Collection
説明
.from
プロパティは、 メールの送信元 アドレスを格納します。
Each email you send out has both the sender and from addresses:
- the sender domain is what the receiving email server gets when opening the session,
- the from address is what the recipient(s) will see.
For better deliverability, it is recommended to use the same from and sender addresses.
.headers
.headers : Collection
説明
.headers
プロパティは、 メッセージ内で現れる順番どおりの EmailHeader
オブジェクトのコレクションを格納します。 This property allows users to add extended (registered) headers or user-defined (not registered, starting with "X") headers.
If an
EmailHeader
object property defines a header such as "from" or "cc" which is already set as a property at the mail level, theEmailHeader
property is ignored.
Every object of the headers collection can contain the following properties:
プロパティ | タイプ | 結果 |
---|---|---|
[].name | text | (mandatory) Header field name as defined in RFC#5322. If null or undefined, the header field is not added to the MIME header. |
[].value | text | Header field values as defined in RFC#5322 |
.htmlBody
.htmlBody : Text
説明
.htmlBody
プロパティは、 (任意、SMTPのみ) HTML形式のメールメッセージ (デフォルトの文字セットは UTF-8)を格納します。 See Handling body part section.
.id
.id : Text
説明
IMAP transporter only.
.id
プロパティは、 IMAP サーバーからの固有IDを格納します。
.inReplyTo
.inReplyTo : Text
説明
.inReplyTo
プロパティは、 カレントメッセージが返信している、元のメッセージのメッセージIDを格納します。
For specific formatting requirements, please consult the RFC#5322.
.keywords
.keywords : Object
説明
.keywords
プロパティは、 各プロパティ名がキーワードであり、各値が true であるキーワードセットのオブジェクトを格納します。
このプロパティは "keywords" ヘッダーです (RFC#4021 参照)。
プロパティ |
---|
.\ |
Reserved keywords:
- $draft - Indicates a message is a draft
- $seen - Indicates a message has been read
- $flagged - Indicates a message needs special attention (e.g., Urgent)
- $answered - Indicates a message has been replied to
- $deleted - Indicates a message to delete
例題
var $mail : Object
$mail.keywords["$flagged"]:=True
$mail.keywords["4d"]:=True
.messageId
.messageId : Text
説明
.messageId
プロパティは、 メッセージ識別ヘッダー ("message-id")を格納します。
This header is usually "lettersOrNumbers@domainname", e.g. "abcdef.123456@4d.com". This unique ID is used in particular on forums or public mailing lists. In general, mail servers automatically add this header to the messages they send.
.receivedAt
.receivedAt : Text
説明
IMAP transporter only.
.receivedAt
プロパティは、 IMAPサーバーにメールが到着した時間の、ISO 8601 UTC フォーマットでのタイムスタンプ (例: 2020-09-13T16:11:53Z)を格納します。
.references
.references : Collection
説明
.references
プロパティは、 返信チェーン内メッセージの、全メッセージID のコレクションを格納します。
For specific formatting requirements, please consult the RFC#5322.
.replyTo
.replyTo : Text
.replyTo : Object
.replyTo : Collection
説明
.replyTo
プロパティは、 返信用 アドレスを格納します。
.sendAt
.sendAt : Text
説明
.sendAt
プロパティは、 メールのタイムスタンプ (ISO 8601 UTCフォーマット)を格納します。
.sender
.sender : Text
.sender : Object
.sender : Collection
説明
.sender
プロパティは、 メールのソース アドレスを格納します。
Each email you send out has both the sender and from addresses:
- the sender domain is what the receiving email server gets when opening the session,
- the from address is what the recipient(s) will see.
For better deliverability, it is recommended to use the same from and sender addresses.
.size
.size : Integer
説明
IMAP transporter only.
.size
プロパティは、 IMAPサーバーから返された Email オブジェクトのサイズ (バイト単位)を格納します。
.subject
.subject : Text
説明
.subject
プロパティは、 メールの件名を格納します。
.textBody
.textBody : Text
説明
.textBody
プロパティは、 (任意、SMTPのみ) 標準テキスト形式のメールメッセージ (デフォルトの文字セットは UTF-8)を格納します。 See Handling body part section.
.to
.to : Text
.to : Object
.to : Collection
説明
.to
プロパティは、 メールのメインの受信者 アドレスを格納します。