SMTP_Charset

4D - Documentation   Français   English   German   Japanese   4D Internet Commands, Theme List   4D Internet Commands, Alphabetical List   Back   Previous   Next

version 6.8.1 (Modified)


SMTP_Charset (encodeHeaders; bodyCharset) Integer

ParameterTypeDescription
encodeHeadersInteger-1 = Use current settings, 0 = Do not manage,
1 = Convert using the specified charset if ISO-8859-1
or ISO-2022-JP, encode extended characters
bodyCharsetInteger-1 = Use current settings, 0 = Do not manage,
1= Convert using the specified charset if ISO-8859-1
or ISO-2022-JP
Function resultIntegerError Code

Description

The SMTP_Charset command allows automatic support of messages containing extended characters while sending them with the SMTP_QuickSend or SMTP_Send commands. If this command is not called or has parameters set to 0, version 6.7 or higher of 4D Internet Commands will work the same way as version 6.5.x.

The SMTP_Charset command allows first, to define if the SMTP_SetPrefs bodyType parameter value must be applied to convert the message headers and body, and second, to define if a header containing extended characters must be encoded using the "=?ISO-8859-1?Q?Test=E9?= …" syntax as specified in the RFC#1342. This command has an interprocess scope and will have effect on all subsequent messages sent using the SMTP_QuickSend and SMTP_Send in any 4D process.

This command is particularly useful for supporting extended characters included in the message headers such as Subject or mail addresses (for example, address encoding such as "=?ISO-8859-1?Q?Test=E9?= <test@n.net >").

Depending on the message headers, encoding (always set to Base64 (except for Subject header) and depending on the SMTP_SetPrefs bodyType parameter value) will be managed as follows:

Subject, Comment (called "unstructured headers"): the full string is encoded if it includes extended characters.

From, To, CC, Bcc, Sender, ReplyTo, InReplyTo (called "structured headers"):

- Any text between angle brackets ("<", ">") is systematically considered as an e-mail address
and is not encoded.
- Special and delimiter characters such as SPC < > ( ) @ , ; : " / ? . = are not encoded.
- Strings delimited by special and delimiter characters are encoded if they include extended
characters.

Address examples:

- someone@somewhere is not encoded;
- Michèle <michele@somewhere>, only Michèle is encoded.

The encodeHeaders parameter specifies how to handle header conversion and encoding while sending a message. Default value is set to 0.

-1:Use current settings;
0:Do not manage;
1:- On one hand, if the SMTP_SetPrefs bodyType parameter sets the character set to ISO-8859-1
or ISO-2022-JP, headers are converted using the specified character set.
- On the other hand, headers are encoded using the following syntax "=? Charset specified
by the SMTP_SetPrefs command? Base64 Encoding?Test=E9?= …" (see RFC#1342) if they
include extended characters, whatever the specified character set.
- Exception: the Subject header will be encoded using the encoding method given by the
bodyType of the SMTP_SetPrefs command if needed.

Note: Extended headers such as "X_…" must use exclusively US ASCII codes.

The bodyCharset parameter specifies how to handle the message body character set conversion while sending a message. Default value is set to 0.

-1: Use current settings;

0: Do not manage;

1: if the SMTP_SetPrefs bodyType parameter sets the character set to ISO-8859-1 or ISO-2022-JP, the message body is converted using the specified character set.

Example

In this example, the subject and the body are converted using the ISO-8859-1 character set, and the subject is encoded following the RFC 1342 syntax:

   SMTP_SetPrefs(1;1;0)
   $err:=SMTP_Charset(1;1)
   $err:=SMTP_QuickSend("mymail.com";"myaddress";"destination";"the Euro €";"the Euro symbol is €") 

See Also

POP3_Charset, SMTP_SetPrefs.


4D - Documentation   Français   English   German   Japanese   4D Internet Commands, Theme List   4D Internet Commands, Alphabetical List   Back   Previous   Next