Beispiel #1
0
        public void UploadMessages(IEnumerable <Message> messages, string path, ref int messagesTransferred)
        {
            Update();

            Folder targetFolder = SelectFolder(path);

            if (targetFolder == null)
            {
                SimpleLog.Instance.Log("Target folder is null");
                return; //Throw some kind of error here so we don't forget why this isn't working in 6 months
            }

            try
            {
                if (messages.Count() == 0)
                {
                    return;
                }
                foreach (Message m in messages)
                {
                    m.Download(ImapX.Enums.MessageFetchMode.Full);
                    if (targetFolder.AppendMessage(m.ToEml()))
                    {
                        SimpleLog.Instance.Log("Succesfully uploaded message " + m.Subject);
                        messagesTransferred++;
                    }
                    else
                    {
                        SimpleLog.Instance.Log("Failed to upload message " + m.Subject);
                    }
                }
            }
            catch (Exception ex)
            {
                SimpleLog.Instance.Log("Exception occured while attempting to upload files " + ex.Message);
            }
        }