C# Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CUnicode C++Unicode CMFCDelphi DLLDelphi ActiveXFoxProJavaPerlPHP 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

 

 

 

 

 

 

Access Email Attachments in Memory (strings and byte arrays)

Download: Chilkat .NET Assemblies

C# sample program showing how to access an email's attachments in memory.

Chilkat.MailMan mailman = new Chilkat.MailMan();

// Any string argument automatically begins the 30-day trial.
mailman.UnlockComponent("30-day trial");

mailman.MailHost = "mail.chilkatsoft.com";
mailman.PopUsername = "***";
mailman.PopPassword = "***";

Chilkat.EmailBundle bundle = mailman.CopyMail();
int i;
int n = bundle.MessageCount;
for (i=0; i<n; i++)
{
    Chilkat.Email email = bundle.GetEmail(i);
    
    int numAttach = email.NumAttachments;
    int j;
    
    for (j=0; j<numAttach; j++)
    {
	string contentType = email.GetAttachmentContentType(j);
	if (contentType.StartsWith("text/"))
	{
	    // We have a text attachment...
	    // Call GetAttachmentString to get the contents of the text attachment.
	    // The 2nd parameter is the charset of the text, which can be something
	    // like "utf-8", "windows-1252", "shift_JIS", "iso-8859-2", etc.
	    // If you're not sure about what to use, use windows-1252.
	    string attachmentContents = email.GetAttachmentString(j,"windows-1252");
	    
	    // ....
	}
	else
	{
	    byte [] attachmentData = email.GetAttachmentData(j);
	    
	    // ...
	}
    }

 

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