Perl Examples

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

Perl Examples

Quick Start
Unicode
Byte Array
Bz2
Certificates
CSV
Email
Encryption
FTP
HTML Conversion
HTTP
IMAP
MHT
MIME
POP3
RSA
S/MIME
Signatures
SMTP
Socket / SSL
Spider
SFTP
SSH Key
SSH
SSH Tunnel
Tar
HTTP Upload
XML
XMP
Zip

More Examples...
String
Amazon S3
Email Object
DKIM / DomainKey
NTLM
FileAccess
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA
Bzip2
LZW

 

 

 

 

 

 

 

Recursively Descend MIME Message

 Chilkat Perl Module Downloads for Windows, Linux, and MAC OS X

Sample program showing how to use recursion in Perl to examine a MIME message and print the message structure.

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

use chilkat;

sub traverseMime {
	
	my $mime = $_[0];
	my $level = $_[1];
   
	$line = "";
		
	for (my $i = 0; $i < $level; $i++) {
		$line = $line . "----";
	}
	
	$line = $line . $mime->contentType();
		
	print $line . "\n";
		
	my $n = $mime->get_NumParts();
	
	for (my $i = 0; $i < $n; $i++) {
		my $part = $mime->GetPart($i);
		traverseMime($part,$level+1);
	}

}

# This example builds a complex email:
# -- one that has both plain-text and HTML alternative bodies.
# -- the HTML has embedded images
# -- there are multiple attachments.
# We then examine the MIME structure using Chilkat MIME.
		
# First, we'll need the email component unlocked...
$mailman = new chilkat::CkMailMan();
$mailman->UnlockComponent("anything for 30-day trial");

# We'll convert a web page into an email with embedded
# images.
$mht = new chilkat::CkMht();
$mht->UnlockComponent("anything for 30-day trial");
		
# Our URL was picked at random...
$email = $mht->GetEmail("http://www.masukolandscaping.com/");
		
# Add a plain-text alternative body.
$email->AddPlainTextAlternativeBody("this is the plain-text alternative...");
		
# Add a few file attachments:
$strContentType = new chilkat::CkString();
# AddFileAttachment returns the auto-selected content-type in strContentType
$email->AddFileAttachment("images/dudeRuby.gif",$strContentType);
$email->AddFileAttachment("blah.txt",$strContentType);
		
# Now we have a complex $email->  Get it as a MIME object and examine
# the structure...
$mime = new chilkat::CkMime();
$mime->UnlockComponent("anything for 30-day trial");
		
$mime = $email->GetMimeObject();
$mime->SaveMime("e.eml");
		
traverseMime($mime,0);
		
# Prints this:

# multipart/mixed
# ----multipart/related
# --------multipart/alternative
# ------------text/plain
# ------------text/html
# --------image/gif
# --------image/gif
# --------image/gif
# --------image/gif
# --------image/gif
# --------image/gif
# --------image/jpeg
# --------image/gif
# --------image/gif
# --------image/gif
# --------image/gif
# --------image/gif
# ----image/gif
# ----text/plain






 

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