コード例 #1
0
 public void DeleteMessages(int[] ids, string folder)
 {
     folder = FileSystem.ToValidPathName(folder);
     try
     {
         string folderName = CreateFolderFullPath(folder);
         foreach (int id in ids)
         {
             string filename = Path.Combine(folderName, string.Format("{0}.eml", id));
             if (File.Exists(filename))
             {
                 File.Delete(filename);
             }
         }
     }
     catch (ArgumentException ex)
     {
         Log.WriteException(ex);
         throw new WebMailIOException(ex);
     }
     catch (UnauthorizedAccessException ex)
     {
         Log.WriteException(ex);
         throw new WebMailIOException(ex);
     }
     catch (IOException ex)
     {
         Log.WriteException(ex);
         throw new WebMailIOException(ex);
     }
 }
コード例 #2
0
 public MailMessage LoadMessage(int id, string folder)
 {
     folder = FileSystem.ToValidPathName(folder);
     try
     {
         string      folderName = CreateFolderFullPath(folder);
         string      filename   = Path.Combine(folderName, string.Format("{0}.eml", id));
         MailMessage msg        = null;
         if (File.Exists(filename))
         {
             msg = new MailMessage();
             msg.LoadMessage(filename);
         }
         return(msg);
     }
     catch (ArgumentException ex)
     {
         Log.WriteException(ex);
         throw new WebMailIOException(ex);
     }
     catch (MailBeeException ex)
     {
         Log.WriteException(ex);
         throw new WebMailMailBeeException(ex);
     }
 }
コード例 #3
0
        public void MoveMessages(int[] ids, string folderSrc, string folderDst)
        {
            folderSrc = FileSystem.ToValidPathName(folderSrc);
            folderDst = FileSystem.ToValidPathName(folderDst);
            try
            {
                string sourceFolder = CreateFolderFullPath(folderSrc);
                string destFolder   = CreateFolderFullPath(folderDst);

                foreach (int id in ids)
                {
                    string sourceFilename = Path.Combine(sourceFolder, string.Format("{0}.eml", id));
                    string destFilename   = Path.Combine(destFolder, string.Format("{0}.eml", id));
                    if (File.Exists(sourceFilename))
                    {
                        File.Move(sourceFilename, destFilename);
                    }
                }
            }
            catch (ArgumentException ex)
            {
                Log.WriteException(ex);
                throw new WebMailIOException(ex);
            }
            catch (UnauthorizedAccessException ex)
            {
                Log.WriteException(ex);
                throw new WebMailIOException(ex);
            }
            catch (IOException ex)
            {
                Log.WriteException(ex);
                throw new WebMailIOException(ex);
            }
        }
コード例 #4
0
 /// <summary>
 /// Create folder on disk
 /// </summary>
 /// <param name="folder"></param>
 /// <returns>Created folder full path.</returns>
 public string CreateFolder(string folder)
 {
     folder = FileSystem.ToValidPathName(folder);
     try
     {
         string folderToCreate = CreateFolderFullPath(folder);
         if (!Directory.Exists(folderToCreate))
         {
             Directory.CreateDirectory(folderToCreate);
         }
         return(folderToCreate);
     }
     catch (ArgumentException ex)
     {
         Log.WriteException(ex);
         throw new WebMailIOException(ex);
     }
     catch (UnauthorizedAccessException ex)
     {
         Log.WriteException(ex);
         throw new WebMailIOException(ex);
     }
     catch (IOException ex)
     {
         Log.WriteException(ex);
         throw new WebMailIOException(ex);
     }
 }
コード例 #5
0
 public void DeleteFolder(string folder)
 {
     folder = FileSystem.ToValidPathName(folder);
     try
     {
         string folderToDelete = CreateFolderFullPath(folder);
         if (Directory.Exists(folderToDelete))
         {
             Directory.Delete(folderToDelete, true);
         }
     }
     catch (ArgumentException ex)
     {
         Log.WriteException(ex);
         throw new WebMailIOException(ex);
     }
     catch (UnauthorizedAccessException ex)
     {
         Log.WriteException(ex);
         throw new WebMailIOException(ex);
     }
     catch (IOException ex)
     {
         Log.WriteException(ex);
         throw new WebMailIOException(ex);
     }
 }
コード例 #6
0
 public void SaveMessage(MailMessage msg, long id, string folder)
 {
     folder = FileSystem.ToValidPathName(folder);
     try
     {
         string folderName = CreateFolderFullPath(folder);
         if (!Directory.Exists(folderName))
         {
             Directory.CreateDirectory(folderName);
         }
         string filename = Path.Combine(folderName, string.Format("{0}.eml", id));
         msg.SaveMessage(filename);
     }
     catch (ArgumentException ex)
     {
         Log.WriteException(ex);
         throw new WebMailIOException(ex);
     }
     catch (MailBeeException ex)
     {
         Log.WriteException(ex);
         throw new WebMailMailBeeException(ex);
     }
 }