Visual C++ Examples

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

C++ Examples

CkString
Byte Array
Bounced Mail
Bz2
Character Encoding
CSV
DH Key Exchange
DKIM/DomainKeys
Digital Certificates
Digital Signatures
DSA
Email
Email Object
Encryption
FTP
HTML Conversion
HTTP
IMAP
MHT / HTML Email
POP3
RSA
S/MIME
SMTP
Socket
Spider
SSH Key
SSH
SSH Tunnel
SFTP
Tar
Upload
XML
XMP
Zip Compression


More Examples...
Amazon S3
NTLM
FileAccess
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
Bzip2
LZW

 

 

 

 

 

 

 

 

Delete IMAP Email

To delete an email, the "Deleted" flag must be set to 1 for each message to be deleted. You must also call Expunge or ExpungeAndClose to remove the emails marked as deleted.

Downloads:

MS Windows Visual C/C++ Libraries
Linux/CentOS C/C++ Libraries
MAC OS X C/C++ Libraries
Solaris C/C++ Libraries
C++ Builder Libraries
#include <CkImap.h>
#include <CkMessageSet.h>

void ChilkatSample(void)
    {
    //  This example deletes email matching a criteria from Inbox.
    CkImap imap;

    bool success;

    //  Anything unlocks the component and begins a fully-functional 30-day trial.
    success = imap.UnlockComponent("Anything for 30-day trial");
    if (success != true) {
        printf("%s\n",imap.lastErrorText());
        return;
    }

    //  Turn on session logging:
    imap.put_KeepSessionLog(true);

    //  Connect to an IMAP server.
    success = imap.Connect("mail.chilkatsoft.com");
    if (success != true) {
        printf("%s\n",imap.lastErrorText());
        return;
    }

    //  Login
    success = imap.Login("myLogin","myPassword");
    if (success != true) {
        printf("%s\n",imap.lastErrorText());
        return;
    }

    //  Select an IMAP mailbox
    success = imap.SelectMailbox("Inbox");
    if (success != true) {
        printf("%s\n",imap.lastErrorText());
        return;
    }

    CkMessageSet *messageSet = 0;
    bool fetchUids;
    fetchUids = true;
    //  Get the message IDs for all emails having "FTP2" in the subject.
    messageSet = imap.Search("SUBJECT FTP2",fetchUids);
    if (messageSet == 0 ) {
        printf("%s\n",imap.lastErrorText());
        return;
    }

    //  Set the Deleted flag for each message:
    success = imap.SetFlags(*messageSet,"Deleted",1);
    if (success != true) {
        printf("%s\n",imap.lastErrorText());
        return;
    }

    //  Expunge and close the mailbox.
    success = imap.ExpungeAndClose();
    if (success != true) {
        printf("%s\n",imap.lastErrorText());
        return;
    }

    //  Display the session log.
    printf("%s\n",imap.sessionLog());

    //  Disconnect from the IMAP server.
    imap.Disconnect();

    delete messageSet;
    }

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

Mail Component · .NET Mail Component · XML Parser