Sample code for 30+ languages & platforms
AutoIt Requires Chilkat v11.0.0+

Build an AMP email with text and HTML fallbacks

See more Email Object Examples

Place text/x-amp-html inside multipart/alternative, before the regular HTML alternative. Use the AMP email validator and meet your provider’s sender requirements before using a dynamic campaign. AMP email MIME structure.

Chilkat AutoIt Downloads

AutoIt
Local $bSuccess = False

;  Assumes Chilkat is unlocked. See Global Unlock Sample.

$oEmail = ObjCreate("Chilkat.Email")
$oEmail.From = "Workshop team <events@example.com>"
$bSuccess = $oEmail.AddTo("Alex Rivera","alex@example.net")
If ($bSuccess <> True) Then
    ConsoleWrite($oEmail.LastErrorText & @CRLF)
    Exit
EndIf

$oEmail.Subject = "Workshop reminder"
$oEmail.Body = "Your workshop starts at 09:00."
$oMimeBytes = ObjCreate("Chilkat.BinData")
$bSuccess = $oEmail.GetMimeBd($oMimeBytes)
If ($bSuccess <> True) Then
    ConsoleWrite($oEmail.LastErrorText & @CRLF)
    Exit
EndIf

$oMime = ObjCreate("Chilkat.Mime")
$bSuccess = $oMime.LoadMimeBd($oMimeBytes)
If ($bSuccess <> True) Then
    ConsoleWrite($oMime.LastErrorText & @CRLF)
    Exit
EndIf

$bSuccess = $oMime.ConvertToMultipartAlt()
If ($bSuccess <> True) Then
    ConsoleWrite($oMime.LastErrorText & @CRLF)
    Exit
EndIf

;  Append the specialist part before the standard HTML fallback.
$oSpecial = ObjCreate("Chilkat.Mime")
$oSpecial.ContentType = "text/x-amp-html"
$oSpecial.Charset = "utf-8"
$oSpecial.SetBody "<!doctype html><html amp4email><head><meta charset='utf-8'><style amp4email-boilerplate>body{visibility:hidden}</style><script async src='https://cdn.ampproject.org/v0.js'></script></head><body><p>Your workshop starts at 09:00.</p></body></html>"
$bSuccess = $oMime.AppendPart($oSpecial)
If ($bSuccess <> True) Then
    ConsoleWrite($oMime.LastErrorText & @CRLF)
    Exit
EndIf

$oStandard = ObjCreate("Chilkat.Mime")
$oStandard.ContentType = "text/html"
$oStandard.Charset = "utf-8"
$oStandard.SetBody "<p>Your workshop starts at <b>09:00</b>.</p>"
$bSuccess = $oMime.AppendPart($oStandard)
If ($bSuccess <> True) Then
    ConsoleWrite($oMime.LastErrorText & @CRLF)
    Exit
EndIf

$bSuccess = $oMime.SaveMime("amp.eml")
If ($bSuccess <> True) Then
    ConsoleWrite($oMime.LastErrorText & @CRLF)
    Exit
EndIf

ConsoleWrite("Saved amp.eml." & @CRLF)