KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Optimize the way you send encoded attachments procedurally
PRODUCT: 4D Internet Commands | VERSION: 2003.2 | PLATFORM: Mac & Win
Published On: March 25, 2004

Compatibility: Version 6.8.x and 2003.x

Using the command SMTP_Attachment, one can easily encode a file that will be attached in an email. The third parameter provides multiple options to choose when encoding your attachment. One thing to consider, the encoding is done during the SMTP_Send command, which can take time executing depending on the size of the attachment. Furthermore, having to send the same message multiple times this way can prove inefficient.

As an alternative, use the IT_Encode command. IT_Encode will encode the file once before executing the SMTP_Send command, removing some of the strain and providing a more efficient solution. For example, to encode into Base64, you may have the following:

$error:=IT_Encode ("";"";2)
$error:=SMTP_Attachment ($smtp_id;"";-2)

Notice that the third parameter of SMTP_Attachment is a negative number. This tells the system that the file has already been encoded and to append the correct header information for the email client to decode. For more information, please refer to the documentation.