Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Lianja) Copy an Email from One Mailbox to AnotherCopies 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.
// 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. loImap = createobject("CkImap") // Turn on session logging: loImap.KeepSessionLog = .T. // Connect to an IMAP server. // Use TLS loImap.Ssl = .T. loImap.Port = 993 llSuccess = loImap.Connect("imap.someMailServer.com") if (llSuccess <> .T.) then ? loImap.LastErrorText release loImap return endif // Login llSuccess = loImap.Login("***","***") if (llSuccess <> .T.) then ? loImap.LastErrorText release loImap return endif // Select an IMAP mailbox llSuccess = loImap.SelectMailbox("Inbox.testing.a") if (llSuccess <> .T.) then ? loImap.LastErrorText release loImap return endif llFetchUids = .T. // Get the message IDs for all emails having "Re:" in the subject. loMessageSet = loImap.Search("SUBJECT Re:",llFetchUids) if (loImap.LastMethodSuccess <> .T.) then ? loImap.LastErrorText release loImap return endif // Copy the messages from "Inbox.testing.a" to "Inbox.testing.b" in one call to CopyMultiple: llSuccess = loImap.CopyMultiple(loMessageSet,"Inbox.testing.b") if (llSuccess <> .T.) then ? loImap.LastErrorText release loImap return endif // Alternatively, loop over each message in the set and // copy each separately: n = loMessageSet.Count if (n > 0) then for i = 0 to n - 1 lnMsgId = loMessageSet.GetId(i) llIsUid = loMessageSet.HasUids llSuccess = loImap.Copy(lnMsgId,llIsUid,"Inbox.testing.c") if (llSuccess <> .T.) then ? loImap.LastErrorText release loImap return endif next endif // Display the session log. ? loImap.SessionLog // Disconnect from the IMAP server. llSuccess = loImap.Disconnect() release loMessageSet release loImap |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.