Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3/4TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

Perl Examples

Web API Categories

ASN.1
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Service Bus
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Compression
DKIM / DomainKey
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
ECC
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
Geolocation
Google APIs
Google Calendar
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text

HTTP
HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
Microsoft Graph
NTLM
OAuth1
OAuth2
OneDrive
OpenSSL
Outlook
PEM
PFX/P12
POP3
PRNG
REST
REST Misc
RSA Encryption
SCP
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
SharePoint
Socket/SSL/TLS
Spider
Stream
Tar Archive
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl

 

 

 

(Perl) Copy an Email from One Mailbox to Another

Copies an email from one IMAP folder to another. After running this example, copies of the email will be present in both source and destination folders.

Chilkat Perl Downloads

Perl Module for Windows, Linux, Alpine Linux,
MAC OS X, Solaris, FreeBSD, OpenBSD,
Raspberry Pi and other single board computers

use chilkat();

# This example requires the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.

# This example copies an email from one mailbox to another.
$imap = chilkat::CkImap->new();

# Turn on session logging:
$imap->put_KeepSessionLog(1);

# Connect to an IMAP server.
# Use TLS
$imap->put_Ssl(1);
$imap->put_Port(993);
$success = $imap->Connect("imap.someMailServer.com");
if ($success != 1) {
    print $imap->lastErrorText() . "\r\n";
    exit;
}

# Login
$success = $imap->Login("***","***");
if ($success != 1) {
    print $imap->lastErrorText() . "\r\n";
    exit;
}

# Select an IMAP mailbox
$success = $imap->SelectMailbox("Inbox.testing.a");
if ($success != 1) {
    print $imap->lastErrorText() . "\r\n";
    exit;
}

$fetchUids = 1;

# Get the message IDs for all emails having "Re:" in the subject.
# messageSet is a MessageSet
$messageSet = $imap->Search("SUBJECT Re:",$fetchUids);
if ($imap->get_LastMethodSuccess() != 1) {
    print $imap->lastErrorText() . "\r\n";
    exit;
}

# Copy the messages from "Inbox.testing.a" to "Inbox.testing.b" in one call to CopyMultiple:
$success = $imap->CopyMultiple($messageSet,"Inbox.testing.b");
if ($success != 1) {
    print $imap->lastErrorText() . "\r\n";
    exit;
}

# Alternatively, loop over each message in the set and
# copy each separately:

$n = $messageSet->get_Count();
if ($n > 0) {
    for ($i = 0; $i <= $n - 1; $i++) {
        $msgId = $messageSet->GetId($i);
        $isUid = $messageSet->get_HasUids();
        $success = $imap->Copy($msgId,$isUid,"Inbox.testing.c");
        if ($success != 1) {
            print $imap->lastErrorText() . "\r\n";
            exit;
        }

    }

}

# Display the session log.
print $imap->sessionLog() . "\r\n";

# Disconnect from the IMAP server.
$success = $imap->Disconnect();


 

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