Zip Component, Email Component, Encryption Component ActiveX Control for Zip Compression .NET Components for ASP.NET
ActiveX and .NET Components for Zip Compression, Encryption, Email, XML, S/MIME, HTML Email, Character Encoding, Digital Certificates, FTP, and more ASP Email ActiveX Component


Index of Chilkat Blog Posts

September 6, 2007

ASP Code to get the Complete MIME for an HTTP Header + Body

This ASP example shows how to get the complete MIME for an HTTP POST request (which includes HTTP uploads). The MIME can include binary data (i.e. binary MIME). In order to run this code, you’ll need the ChilkatUtil.dll, which is an ActiveX available at this URL:
http://www.chilkatsoft.com/preRelease/ChilkatUtil.zip

You’ll also need ChilkatMime.dll:
http://www.chilkatsoft.com/preRelease/ChilkatMime.zip

This example was prompted by the need to process MM7 POSTs. The intent is to capture the entire MIME message in the Chilkat MIME ActiveX, and then use Chilkat MIME to access the parts of the MM7 request. Here is the sample code:

Note: Chilkat MIME is a commercial component that would need to be licensed. The ChilkatUtil.dll is freeware and can be used without licensing.

<html>
<body>
<%
set d = Server.CreateObject("Chilkat.CkData")
d.LoadString Request.ServerVariables("ALL_RAW")
d.AppendString vbCrLf
	
n = Request.TotalBytes
d.AppendBinary Request.BinaryRead(n)
	
set mimeObj = Server.CreateObject("Chilkat.Mime")
success = mimeObj.UnlockComponent("Anything for 30-day trial")
if (success = 0) then
	' Failed.
end if
	
' You now have the complete HTTP request as a MIME document that can be parsed
' using Chilkat MIME.
' LoadMimeBytes loads the MIME document into the MIME object:
mimeObj.LoadMimeBytes d.GetBinary()
	
' The remainder of the code displays a few headers and displays
' the complete MIME.  The important point is that you now have the
' complete HTTP request + body as MIME that can be accessed/manipulated
' using Chilkat MIME.
response.write "<p>"
response.write mimeObj.ContentType
response.write "</p>"
response.write "<p>"
response.write mimeObj.Referer
response.write "</p>"
response.write "<pre>"
' Assuming the MIME does not have binary content...
' Display the entire MIME message.
response.write mimeObj.GetMime()
response.write "
" %>


Privacy Statement. Copyright 2000-2011 Chilkat Software, Inc. All rights reserved.
Send feedback to support@chilkatsoft.com

Components for Microsoft Windows XP, 2000, 2003 Server, Vista, Windows 7, and Windows 95/98/NT4.