Perl Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript



Perl Examples

Quick Start
Perl Unicode
Perl Byte Array
Perl Certs
Perl Email
Perl Encryption
Perl FTP
HTML-to-XML
Perl HTTP
Perl IMAP
Perl MHT
Perl MIME
Perl RSA
Perl S/MIME
Perl Signatures
Perl Socket
Perl Spider
Perl Tar
Perl Upload
Perl XML
Perl XMP
Perl Zip

More Examples...
String
Email Object
POP3
SMTP
RSS
Atom
Self-Extractor

Unreleased...
Service
PPMD
Deflate
Bzip2
LZW
Bz2
DH Key Exchange
DSA
Icon

 

 

 

 

 

 

 

Load Binary File into MIME Body

Perl example script showing how to load a binary file into a MIME body. This example loads a GIF image file into the MIME body. The encoding (base64) and content-type are automatically determined by the file extension. (Text files may also be loaded this way.)

Download Perl Programming Example Scripts

# file: mimeBinaryBody.pl
# Perl MIME parsing script / create MIME in Perl.

use chilkat;

# 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.
# 
# 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.

		
$mime = new chilkat::CkMime();
$mime->UnlockComponent("anything for 30-day trial");
	    
# Load the MIME body with a GIF file.
$mime->SetBodyFromFile("images/dudePerl.gif");
		
# Print the MIME:
print $mime->mime() . "\n\n";

# Prints this:
# content-disposition: attachment;
# 	 filename="dudeRuby.gif"
# content-transfer-encoding: base64
# content-type: image/gif;
# 	name="dudeRuby.gif"
# 
# R0lGODlhZABkAPf/AP////ry8vrx8Pnx8fnw8PXn5vXl5PTk4/Pg4PPf3/DX1+7Pz+3R0e3L
# y+zQz+vg4OvV1evKyuvDw+rk5Ojo6Oi/v+fBweW6uuS/v+O/v+Kvr+G/v+Gyst6kpNyWltui
# otqurdm4uNmMi9eendePj9eIh9bKyta1tdW+vtWTk9WSkdOPj9KmpdJ5eNGAgNCEhMy8vMp1
# ...
# OPmTL5ERCSRh53on0rlzwUcT7AZO8ctyUFat+gR4UEKNQyplMJkekRCqDxEgERAAOw==


		
# Remove the "name" attribute from the content-type:
$mime->put_Name("");
# Remove the "filename" attribute from the content-disposition:
$mime->put_Filename("");
# Remove the content-disposition altogether:
$mime->put_Disposition("");
		
# Print the MIME:
print $mime->mime() . "\n\n";

# Prints this:
# content-transfer-encoding: base64
# content-type: image/gif
# 
# R0lGODlhZABkAPf/AP////ry8vrx8Pnx8fnw8PXn5vXl5PTk4/Pg4PPf3/DX1+7Pz+3R0e3L
# y+zQz+vg4OvV1evKyuvDw+rk5Ojo6Oi/v+fBweW6uuS/v+O/v+Kvr+G/v+Gyst6kpNyWltui
# otqurdm4uNmMi9eendePj9eIh9bKyta1tdW+vtWTk9WSkdOPj9KmpdJ5eNGAgNCEhMy8vMp1
# ...
# OPmTL5ERCSRh53on0rlzwUcT7AZO8ctyUFat+gR4UEKNQyplMJkekRCqDxEgERAAOw==






 

Need a specific example? Send a request to support@chilkatsoft.com

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