C# Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

C# Examples

Bounced Mail
Bz2
Character Encoding
CSV
DKIM / DomainKey
Digital Certificates
Digital Signatures
Email
Email Object
FTP
HTML Conversion
HTTP
IMAP
Encryption
MHT / HTML Email
MIME
POP3
RSA
S/MIME
SMTP
Socket
Spider
SSH
SSH Tunnel
SSH Key
SFTP
Tar Archive
Upload
XML
XMP
Zip Compression


More Examples...
Amazon S3
NTLM
FileAccess
RSS
Atom
String
Byte Array
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA
Bzip2
LZW

 

 

 

 

 

 

Load File into MIME Body

Download: 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
must be downloaded and installed separately at http://www.chilkatsoft.com/downloads.asp.
Once installed, add a reference to the DLL in the project by following the instructions at
http://www.example-code.com/csharp/step2.asp

 

© 2000-2012 Chilkat Software, Inc. All Rights Reserved.

Email Component · XML Parser