Emails with conzept 16 (Part 2)

In article E-Mails mit CONZEPT 16, I explained how you can create, format and send emails. However, I have not gone into some of the functions, such as including files in the HTML text or adding attachments with a special MIME type. These and other topics are covered in the following article.


Info:

The automatic e-mail notification also uses the mail commands internally.

This article covers the following topics:


Encoding

Each file in an e-mail, both the message content and the attachment, is encoded in a specific way. There are three coding options available:

  • base64 (_MimeTE_B64)
    A readable character string is generated from any byte sequence using a “3 to 4″conversion. This is the standard encoding method for attachments.
  • quoted-printable (_MimeTE_QP)
    Control characters, ASCII characters above 127 and some special characters are replaced by a hexadecimal representation. This is the standard encoding method for texts.
  • 8-Bit (_MimeTE_8B)
    No encoding takes place. This option can only be used for texts without control characters.

The “TE” in the constants stands for Transfer Encoding.

// Do not encode plain text
tMail->MailData(_MailFile | _MimeTE_8B, _Sys->spPathDesktop + 'welcome.txt');

// Quoted-printable encoding of Word file
tMail->MailData(_MailFile | _MimeAppMSWORD | _MimeTE_QP, _Sys->spPathMyDocuments + 'welcome.dox');

Character set

A character set can also be specified for the message content. The ISO-8859-1 character set is used by default. However, this only contains some of the Western European special characters. For example, the euro symbol is missing. Alternatively, one of the following character sets can be used.

  • _MimeCS_IBM437 (Codepage 437)
  • _MimeCS_IBM850 (Codepage 850)
  • _MimeCS_UTF8 (Unicode)

Das “CS” in den Konstanten steht für Charset.

// HTML text in UTF-8 character set
tMail->MailData(_MailFile | _MimeTextHTML | _MimeCS_UTF8, _Sys->spPathDesktop + 'welcome.html');

Embedding attachments in the HTML text

When sending an HTML mail, attachments can be embedded in the message. To do this, the constant _MimeRelated must be used when attaching the file. Furthermore, the HTML reference must be specified in the fifth argument. The HTML reference is the name of the file, which is specified in the src attribute of an img element, for example.

It is possible to specify both a complete URI and a symbolic name. This allows a complete HTML page to be sent by e-mail without any changes.

HTML-text:

<html>
<body>
<img src="http://www.myaddress.com/images/mailheader.png"/>
...
<img src="mailfooter.png"/>
</body>
</html>

To embed the images in the HTML mail, they must be attached as follows:

// mailheader.png einbetten
tMail->MailData(_MailFile | _MimeImagePNG, _Sys->spPathMyPictures + 'header.png',
                '', 'http://www.myaddress.com/images/mailheader.png');

// embed mailfooter.png
tMail->MailData(_MailFile | _MimeImagePNG, _Sys->spPathMyPictures + 'footer.png',
                '', 'mailfooter.png');

Using special MIME types

The MIME type must be specified for attachments. If a MIME type is to be used that is not defined via a conzept 16 constant,
one of the following constants can be used:

  • _MimeOtherB64 – The file is base64 encoded.
  • _MimeOtherQP – The file is encoded as printed quotable.
  • _MimeOther8B – The file is not encoded.

The MIME type is passed as an alpha value in the fourth argument.

An overview of all known MIME types can be found under SELFHTML.

// Audio file as an attachment
tMail->MailData(_MailFile | _MimeOtherB64, _Sys->spPathMyMusic + 'mario.wav','audio/x-wav');

// RTF text as an attachment
tMail->MailData(_MailFile | _MimeOtherQP, _Sys->spPathMyDocuments + 'info.rtf','text/rtf');

If no MIME type is defined for a file, e.g. database definition (.d01), a general MIME type can be defined with the constant _MimeApp.

// Add database definition
tMail->MailData(_MailFile | _MimeApp, _Sys->spPathDesktop + 'update.d01');

Leave a Reply

Your email address will not be published. Required fields are marked *

Leave the field below empty!

Get your Trial Version now!

Test yeet free of charge

Deine Trial Version - jetzt anfordern!

Teste yeet - unverbindlich und kostenfrei

IHRE EVALUIERUNGSLIZENZ - JETZT ANFORDERN!

TESTEN SIE DIE CONZEPT 16 VOLLVERSION - UNVERBINDLICH und KOSTENFREI

Subscribe to our newsletter

[cleverreach_signup]
WordPress Cookie Notice by Real Cookie Banner