Classic ASP
Classic ASP
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 Classic ASP Downloads
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0
' Demonstrates the Mime.NewMultipartAlternative method, which initializes the object as an empty
' multipart/alternative entity, clearing any existing content. It takes no arguments.
set mime = Server.CreateObject("Chilkat.Mime")
success = mime.NewMultipartAlternative()
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( mime.LastErrorText) & "</pre>"
Response.End
End If
' 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.
set textPart = Server.CreateObject("Chilkat.Mime")
success = textPart.SetBodyFromPlainText("Hello (plain text version).")
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( textPart.LastErrorText) & "</pre>"
Response.End
End If
success = mime.AppendPart(textPart)
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( mime.LastErrorText) & "</pre>"
Response.End
End If
set htmlPart = Server.CreateObject("Chilkat.Mime")
success = htmlPart.SetBodyFromHtml("<html><body><b>Hello</b> (HTML version).</body></html>")
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( htmlPart.LastErrorText) & "</pre>"
Response.End
End If
success = mime.AppendPart(htmlPart)
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( mime.LastErrorText) & "</pre>"
Response.End
End If
Response.Write "<pre>" & Server.HTMLEncode( "Number of alternatives: " & mime.NumParts) & "</pre>"
%>
</body>
</html>