public void AddAttachmentToEmail(string attachmentName, string attachmentContent)
        {
            byte[] byteArray = Encoding.ASCII.GetBytes(attachmentContent);
            var stream = new MemoryStream(byteArray);

            var fileId = AttachmentFolder.Save(stream);

            var emailAttachment = new LocalStoredAttachment {FileId = fileId, FileName = attachmentName};

            _emailAttachments.Add(emailAttachment);
        }
        private List<LocalStoredAttachment> CreateAttachments(IEnumerable<attachment> attachments)
        {
            var storedAttachments = new List<LocalStoredAttachment>();

            foreach (var attachment in attachments)
            {
                var attachmentFileName = GetAttachmentFileName(attachment);
                FileId fileId = null;

                try
                {
                    fileId = SaveAttachmentFile(attachment);

                    var localAttachment = new LocalStoredAttachment
                    {
                        FileId = fileId,
                        FileName = attachmentFileName,
                        Description = attachment.desc,
                        OwnerId = ObjectFactory.GetInstance<IUserMapper>().GetTpIdBy(attachment.attacher),
                        CreateDate = CreateDateConverter.ParseFromBugzillaLocalTime(attachment.date)
                    };

                    storedAttachments.Add(localAttachment);
                }
                catch (Exception ex)
                {
                    ObjectFactory.GetInstance<IActivityLogger>().Error(
                        string.Format("Cannot import attachment. Bugzilla Bug ID: {1}; File name: {0}", attachmentFileName, bug_id), ex);

                    if (fileId != null && File.Exists(AttachmentFolder.GetAttachmentFileFullPath(fileId)))
                    {
                        AttachmentFolder.Delete(new[] {fileId});
                    }
                }
            }

            return storedAttachments;
        }