Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
Load File into MIME BodyDownload: Chilkat .NET Assemblies C# example program showing how to load the complete contents of a file into a MIME body.
/*
A MIME body can be loaded with the contents of a file.
The Chilkat MIME component automatically maps the file extension
to a content-type. If no mapping is found, the content-type is
set to application/octet-stream and the content-transfer-encoding
is set to base64. Otherwise the content-transfer-encoding
is set to what is appropriate for the file contents.
Information about the filename is also automatically saved to
the content-disposition header field, and a "name" property is
automatically added to the content-type header field.
Note: content-transfer-encoding and content-type can be updated
after loading the body from a file by simply setting the ContentType
and Encoding properties. The other header fields and attributes
can also be removed.
*/
Chilkat.Mime mime = new Chilkat.Mime();
mime.UnlockComponent("anything for 30-day trial");
// Load the MIME body with a GIF file.
mime.SetBodyFromFile("dude.gif");
// Let's see what we get:
textBox1.Text = mime.GetMime();
/* Produces this MIME:
content-disposition: attachment;
filename="dude.gif"
content-transfer-encoding: base64
content-type: image/gif;
name="dude.gif"
R0lGODlhZABkAPf/AP////f39+fn7+/v9/f3/+fn99bW597e79bW78bG3s7O57291rW1zsbG
57293rW11q2tzqWlxq2t1qWlzpycxpSUvYyMtYSErZyczpSUxoyMvYSEtXt7rYSEvXt7tXNz
rWtrpWNjnFpalGNjpVJSjFpanEpKhFJSlEJCe0pKjEJChDk5czk5ezExazExcykpYykpayEh
...
*/
// Remove the "name" attribute from the content-type:
mime.Name = "";
// Remove the "filename" attribute from the content-disposition:
mime.Filename = "";
// Remove the content-disposition altogether:
mime.Disposition = "";
Important: The download for this
example does not contain the ChilkatDotNet.dll which |
© 2000-2012 Chilkat Software, Inc. All Rights Reserved.