C# Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript



C# Examples

Bounced Mail
Character Encoding
Digital Certificates
Digital Signatures
Email
FTP
HTML to XML
HTTP
IMAP
Encryption
MHT / HTML Email
MIME
RSA Encryption
S/MIME
Socket
Spider
Tar Archive
Upload
XML
XMP
Zip Compression


More Examples...
Email Object
POP3
SMTP
RSS
Atom
String
Byte Array
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA

Unreleased...
Bzip2
LZW
Bz2
Icon

 

 

 

 

 

 

Delete Email from an IMAP Mailbox

C# example to delete email from an IMAP mailbox.

    // Delete all email in the mailbox with "#SPAM#" in the subject.
    private void button8_Click(object sender, System.EventArgs e)
    {
	Chilkat.Imap imap = new Chilkat.Imap();
	imap.UnlockComponent("Anything for 30-day trial");
	
	// If your IMAP server needs SSL, set the Ssl property = true
	// and set the IMAP port to 993.
	// imap.Ssl = true;
	// imap.Port = 993;
	imap.Connect("mail.chilkatsoft.com");
	
	// Login to an email account.
	bool b = imap.Login("myLogin", "myPassword");
	if (!b)
	{
	    MessageBox.Show("Login Failed!");
	    return;
	}
    
	// Select the mailbox to read.
	b = imap.SelectMailbox("INBOX");
	if (!b)
	{
	    MessageBox.Show(imap.LastErrorText);
	    return;
	}
	
	// Get the UIDs for all e-mail with "#SPAM#" in the Subject.
	// (The pound sign is NOT a special (wildcard) character.)
	bool fetchUids = true;
	Chilkat.MessageSet mset = imap.Search("SUBJECT \"#SPAM#\"",fetchUids);

	// Mark all the messages in the set for deletion
	// Passing a 1 in the last argument marks each message for deletion,
	// passing a 0 un-deletes the email.  However once the email is
	// expunged, it cannot be un-deleted.
	b = imap.SetFlags(mset, "Deleted", 1);
	if (!b)
	{
	    MessageBox.Show(imap.LastErrorText);
	    return;
	}
	
	// The messages are deleted when expunged, so do it here
	// (and also close the mailbox)
	b = imap.ExpungeAndClose();
	if (!b)
	{
	    MessageBox.Show(imap.LastErrorText);
	    return;
	}
	
	// Disconnect from the IMAP server.
	imap.Logout();
	imap.Disconnect();	
	
	MessageBox.Show("Finished!");	
    
    }

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/vbdotnet/step2.asp

 

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

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

Email Component · XML Parser