Ruby Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript



Ruby
Examples

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

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

 

 

 

 

 

 

 

Read POP3 Email

Ruby script to read POP3 email.

Download Ruby Programming Example Scripts

# file: CopyMail.rb

# Ruby script to read a POP3 mailbox leaving the email on the mail server.

require 'chilkat'

# Create an instance of the mailman object for reading POP3 email.
mailman = Chilkat::CkMailMan.new()
mailman.UnlockComponent("anything for 30-day trial")

# Set your POP3 server's hostname and login/password
mailman.put_MailHost("mail.chilkatsoft.com")
mailman.put_PopUsername("myLogin")
mailman.put_PopPassword("myPassword")

# Download all the email in the mailbox without removing the email.
bundle = mailman.CopyMail()
if bundle == nil
	# Failed to download email.
	mailman.SaveLastError("errorLog.txt")
else	
	# Save the entire email bundle as XML.
	bundle.SaveXml("emailBundle.xml")
	
	# Loop over each email, print the From address and Subject, and save
	# each email to a .eml (MIME message source) file.
	numMessages = bundle.get_MessageCount()

	subject = Chilkat::CkString.new()
	from = Chilkat::CkString.new()
	for i in 0..(numMessages-1)
		email = bundle.GetEmail(i)
		email.get_Subject(subject)
		email.get_From(from)
		print "From:    " + from.getUtf8() + "\n"
		print "Subject: " + subject.getUtf8() + "\n\n"
		
		emlFilename = "email_"+i.to_s()+".eml"
		email.SaveEml(emlFilename)
	end
end





 

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

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