Sample code for 30+ languages & platforms
AutoIt

MIME Content Part Descriptor Properties

See more MIME Examples

Demonstrates the properties that describe an individual MIME content part: Charset (the charset parameter of Content-Type), Encoding (the Content-Transfer-Encoding), Disposition (the Content-Disposition value), Filename (the filename parameter of Content-Disposition), and Name (the name parameter of Content-Type). Each is set and then read back, and the effect is visible in the serialized MIME header.

Background. These properties operate on the current MIME entity's header fields. Filename and Name are receiver-facing labels, not local filesystem paths, and Charset is meaningful for text parts.

Chilkat AutoIt Downloads

AutoIt
Local $bSuccess = False

$oMime = ObjCreate("Chilkat.Mime")
$bSuccess = $oMime.SetBodyFromPlainText("The quick brown fox.")
If ($bSuccess = False) Then
    ConsoleWrite($oMime.LastErrorText & @CRLF)
    Exit
EndIf

;  Charset is the charset parameter of the Content-Type header field (meaningful for text parts).
$oMime.Charset = "utf-8"

;  Encoding is the Content-Transfer-Encoding for this part.
$oMime.Encoding = "quoted-printable"

;  Disposition, Filename, and Name describe how a receiver should present the part.
;  Filename is the filename parameter of Content-Disposition; Name is the name parameter of
;  Content-Type.  Both are receiver-facing names, not local filesystem paths.
$oMime.Disposition = "attachment"
$oMime.Filename = "note.txt"
$oMime.Name = "note.txt"

;  Read the descriptors back.
ConsoleWrite("Charset = " & $oMime.Charset & @CRLF)
ConsoleWrite("Encoding = " & $oMime.Encoding & @CRLF)
ConsoleWrite("Disposition = " & $oMime.Disposition & @CRLF)
ConsoleWrite("Filename = " & $oMime.Filename & @CRLF)
ConsoleWrite("Name = " & $oMime.Name & @CRLF)

;  The descriptors appear in the serialized MIME header.
Local $sMimeStr = $oMime.GetMime()
If ($oMime.LastMethodSuccess = False) Then
    ConsoleWrite($oMime.LastErrorText & @CRLF)
    Exit
EndIf

ConsoleWrite($sMimeStr & @CRLF)