Dart.Mail Namespace > ImapMessage Class : CopyTo Method |
Public Sub CopyTo( _ ByVal destination As Mailbox _ )
Dim instance As ImapMessage Dim destination As Mailbox instance.CopyTo(destination)
public void CopyTo( Mailbox destination )
public: void CopyTo( Mailbox* destination )
public: void CopyTo( Mailbox^ destination )
Exception | Description |
---|---|
ProtocolException | Bad IMAP protocol response received from server. |
System.Net.Sockets.SocketException | A communications failure has occurred. |
This method copies the message to the specified mailbox with the IMAP COPY command.
private void getMessages(object state) { //Configure server and account info imap1.Session.RemoteEndPoint = new Dart.Mail.IPEndPoint(myServer, Imap.GetDefaultPort(imap1.Session)); imap1.Session.Username = myUsername; imap1.Session.Password = myPassword; //Connect and log into the account imap1.Connect(); imap1.Authenticate(); //Set the selected mailbox to the Inbox imap1.SelectedMailbox = imap1.Mailboxes["INBOX"]; // Construct the search "SEARCH SINCE 1-Jan-2012 NOT FROM JACKSON" ImapSearchParameter[] criteria = new ImapSearchParameter[] { new ImapSearchParameter(ImapCriterion.Since, "1-Jan-2012"), new ImapSearchParameter(ImapCriterion.Not, ""), new ImapSearchParameter(ImapCriterion.From, "JACKSON") }; // Perform the search ImapMessage[] messages = imap1.SelectedMailbox.Search(criteria); //Copy all messages that meet the criteria to the 'Save' mailbox foreach (ImapMessage imapMessage in messages) imapMessage.CopyTo(imap1.Mailboxes["Save"]); //Gracefully logout imap1.Close(); }
Private Sub getMessages(ByVal state As Object) 'Configure server and account info imap1.Session.RemoteEndPoint = New Dart.Mail.IPEndPoint(myServer, Imap.GetDefaultPort(imap1.Session)) imap1.Session.Username = myUsername imap1.Session.Password = myPassword 'Connect and log into the account imap1.Connect() imap1.Authenticate() 'Set the selected mailbox to the Inbox imap1.SelectedMailbox = imap1.Mailboxes("INBOX") ' Construct the search "SEARCH SINCE 1-Jan-2012 NOT FROM JACKSON" Dim criteria() As ImapSearchParameter = { New ImapSearchParameter(ImapCriterion.Since, "1-Jan-2012"), New ImapSearchParameter(ImapCriterion.Not, ""), New ImapSearchParameter(ImapCriterion.From, "JACKSON") } ' Perform the search Dim messages() As ImapMessage = imap1.SelectedMailbox.Search(criteria) 'Copy all messages that meet the criteria to the 'Save' mailbox For Each imapMessage As ImapMessage In messages imapMessage.CopyTo(imap1.Mailboxes("Save")) Next imapMessage 'Gracefully logout imap1.Close() End Sub