2

How I can to move emails from inbox to some folder, for example folder "test"

Pop3Client client = new Pop3Client()

client contains method to get email in html, xml, etc. also delete email or delete all emails, but I need to move some email to another folder, it is possible ?

Alex
  • 8,908
  • 28
  • 103
  • 157
  • 2
    http://stackoverflow.com/questions/6067618/does-the-pop3-protocol-support-a-folder-system – J. Steen Jan 19 '15 at 09:05
  • If possible why not use rules? https://support.office.com/en-us/article/Manage-email-messages-by-using-rules-50307363-0e79-4f6a-95c0-04b922a2ff13?ui=en-US&rs=en-001&ad=US – Paul Zahra Jan 19 '15 at 09:21

2 Answers2

2

OpenPop implements the POP3 protocol. This protocol is old, and does not know about such things as folders. Therefore, the OpenPop implementation cannot handle folders as well.

If you need to use folders, consider using some IMAP client instead. IMAP is a newer and more modern protocol.

foens
  • 8,642
  • 2
  • 36
  • 48
0

As J. Steen has pointed out. No, you can't with OpenPop.

Just encase you still want to do it and it wasn't a purely academic question. Taken from MSDN

How to: Programmatically Move Items in Outlook

This example moves unread e-mail messages from the Inbox to a folder named Test. The example only moves messages that have the word Test in the Subject field.

Applies to: The information in this topic applies to application-level projects for Outlook 2013 and Outlook 2010. For more information, see Features Available by Office Application and Project Type.

private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
    this.Application.NewMail += new Microsoft.Office.Interop.Outlook.
        ApplicationEvents_11_NewMailEventHandler
        (ThisAddIn_NewMail);
}

private void ThisAddIn_NewMail()
{
    Outlook.MAPIFolder inBox = (Outlook.MAPIFolder)this.Application.
        ActiveExplorer().Session.GetDefaultFolder
        (Outlook.OlDefaultFolders.olFolderInbox);
    Outlook.Items items = (Outlook.Items)inBox.Items;
    Outlook.MailItem moveMail = null;
    items.Restrict("[UnRead] = true");
    Outlook.MAPIFolder destFolder = inBox.Folders["Test"];
    foreach (object eMail in items)
    {
        try
        {
            moveMail = eMail as Outlook.MailItem;
            if (moveMail != null)
            {
                string titleSubject = (string)moveMail.Subject;
                if (titleSubject.IndexOf("Test") > 0)
                {
                    moveMail.Move(destFolder);
                }
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    }
}
Paul Zahra
  • 9,522
  • 8
  • 54
  • 76