4D Internet Commands v16

SMTP_Charset

Home

 
4D Internet Commands v16
SMTP_Charset

SMTP_Charset 


 

SMTP_Charset ( encodeHeaders ; bodyCharset ) -> Function result 
Parameter Type   Description
encodeHeaders  Integer in -1 = Use current settings, 0 = Use default settings, 1 = Convert using the specified charset
bodyCharset  Integer in -1 = Use current settings, 0 = Use default settings, 1= Convert using the specified charset
Function result  Integer in Error Code

The SMTP_Charset command allows automatic support of messages containing extended characters while sending them with the SMTP_QuickSend or SMTP_Send commands.

The SMTP_Charset command allows first, to define if the SMTP_SetPrefs charset&Encoding parameter value must be applied to convert the message headers, attachment filenames and body, and second, to define if a header (or attachment filename) containing extended characters must be encoded using the “=?ISO-8859-1?Q?Test=E9?= …” syntax as specified in the RFC1342. 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 >”).

The message headers and attachment filenames will be encoded as follows, according to RFC 1342:

  • Subject, Comment and attachment filenames: the full string is encoded in base 64 if it includes extended characters.
  • From, To, CC, Bcc, Sender, ReplyTo, InReplyTo:
    • 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 in base 64 if they include extended
      characters.
    • Address examples:
      someone@somewhere is not encoded;
      Michèle <michele@somewhere>, only Michèle is encoded.
  • Other headers are not 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: Default value: charset is UTF-8 for subject, ISO-8859-1 for other fields;
  • 1: The charset for headers and attachment filenames is defined by the SMTP_SetPrefs charset&Encoding parameter

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

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

  • -1: Use current settings;
  • 0: Default value: UTF-8 base 64;
  • 1: Use charset and encoding defined by the SMTP_SetPrefs charset&Encoding parameter

Note: We recommend using default settings, which are appropriate for most current systems/applications.

Example  

In this example, the subject and the body are converted using the UTF-8 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

 
PROPERTIES 

Product: 4D Internet Commands
Theme: IC Send Mail
Number: 88892

 
HISTORY 

Modified: 4D Internet Commands 6.8.1
Modified: 4D v16

 
ARTICLE USAGE

4D Internet Commands ( 4D Internet Commands v16)