VBScript Requires Chilkat v11.0.0+
VBScript
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 VBScript Downloads
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
'Create a Unicode (utf-16) output text file.
Set outFile = fso.CreateTextFile("output.txt", True, True)
success = 0
' Assumes Chilkat is unlocked. See Global Unlock Sample.
set email = CreateObject("Chilkat.Email")
email.From = "Workshop team <events@example.com>"
success = email.AddTo("Alex Rivera","alex@example.net")
If (success <> 1) Then
outFile.WriteLine(email.LastErrorText)
WScript.Quit
End If
email.Subject = "Workshop reminder"
email.Body = "Your workshop starts at 09:00."
set mimeBytes = CreateObject("Chilkat.BinData")
success = email.GetMimeBd(mimeBytes)
If (success <> 1) Then
outFile.WriteLine(email.LastErrorText)
WScript.Quit
End If
set mime = CreateObject("Chilkat.Mime")
success = mime.LoadMimeBd(mimeBytes)
If (success <> 1) Then
outFile.WriteLine(mime.LastErrorText)
WScript.Quit
End If
success = mime.ConvertToMultipartAlt()
If (success <> 1) Then
outFile.WriteLine(mime.LastErrorText)
WScript.Quit
End If
' Append the specialist part before the standard HTML fallback.
set special = CreateObject("Chilkat.Mime")
special.ContentType = "text/x-amp-html"
special.Charset = "utf-8"
special.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>"
success = mime.AppendPart(special)
If (success <> 1) Then
outFile.WriteLine(mime.LastErrorText)
WScript.Quit
End If
set standard = CreateObject("Chilkat.Mime")
standard.ContentType = "text/html"
standard.Charset = "utf-8"
standard.SetBody "<p>Your workshop starts at <b>09:00</b>.</p>"
success = mime.AppendPart(standard)
If (success <> 1) Then
outFile.WriteLine(mime.LastErrorText)
WScript.Quit
End If
success = mime.SaveMime("amp.eml")
If (success <> 1) Then
outFile.WriteLine(mime.LastErrorText)
WScript.Quit
End If
outFile.WriteLine("Saved amp.eml.")
outFile.Close