private static void AddEncryptedFiled(ref MailMessage mail, ref Collection <string> list, ref string password) { DirectoryManager.CreateTempFolder(); for (int i = 0; i < list.Count; i++) { var item = list[i]; string filePath = item; string destPath = DirectoryManager.tempfolderPath + Utils.GetFileNameFromPath(item) + ".lock"; IFileEncryption fileEncryption = new FileEncryptionCBC(); fileEncryption.EncryptFile(filePath, destPath, password); mail.Attachments.Add(new Attachment(destPath)); } }