Visual FoxPro
Visual FoxPro
Create a multipart/alternative MIME Entity
See more MIME Examples
Demonstrates the Chilkat Mime.NewMultipartAlternative method, which initializes the object as an empty multipart/alternative entity. It takes no arguments; the alternative representations are then appended.
Background:
multipart/alternative holds several renderings of the same content and lets the client pick the best one it can display — the standard way to send an email as both plain text and HTML. Order matters: parts go from least to most preferred, so the plain-text version comes first and the HTML last, and a client shows the last one it understands.Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loMime
LOCAL loTextPart
LOCAL loHtmlPart
lnSuccess = 0
* Demonstrates the Mime.NewMultipartAlternative method, which initializes the object as an empty
* multipart/alternative entity, clearing any existing content. It takes no arguments.
loMime = CreateObject('Chilkat.Mime')
lnSuccess = loMime.NewMultipartAlternative()
IF (lnSuccess = 0) THEN
? loMime.LastErrorText
RELEASE loMime
CANCEL
ENDIF
* multipart/alternative holds two representations of the SAME content; the client displays the
* last one it can render. Add a plain-text part, then an HTML part.
loTextPart = CreateObject('Chilkat.Mime')
lnSuccess = loTextPart.SetBodyFromPlainText("Hello (plain text version).")
IF (lnSuccess = 0) THEN
? loTextPart.LastErrorText
RELEASE loMime
RELEASE loTextPart
CANCEL
ENDIF
lnSuccess = loMime.AppendPart(loTextPart)
IF (lnSuccess = 0) THEN
? loMime.LastErrorText
RELEASE loMime
RELEASE loTextPart
CANCEL
ENDIF
loHtmlPart = CreateObject('Chilkat.Mime')
lnSuccess = loHtmlPart.SetBodyFromHtml("<html><body><b>Hello</b> (HTML version).</body></html>")
IF (lnSuccess = 0) THEN
? loHtmlPart.LastErrorText
RELEASE loMime
RELEASE loTextPart
RELEASE loHtmlPart
CANCEL
ENDIF
lnSuccess = loMime.AppendPart(loHtmlPart)
IF (lnSuccess = 0) THEN
? loMime.LastErrorText
RELEASE loMime
RELEASE loTextPart
RELEASE loHtmlPart
CANCEL
ENDIF
? "Number of alternatives: " + STR(loMime.NumParts)
RELEASE loMime
RELEASE loTextPart
RELEASE loHtmlPart