private void UploadToDocuments(AttachmentStream file, string contentType, MailBox mailbox, ILogger log) { try { var uploadedFileId = ApiHelper.UploadToDocuments(file.FileStream, file.FileName, contentType, mailbox.EMailInFolder, true); log.Debug("ApiHelper.UploadToDocuments() -> uploadedFileId = {0}", uploadedFileId); } catch (ApiHelperException ex) { if (ex.StatusCode == HttpStatusCode.NotFound || ex.StatusCode == HttpStatusCode.Forbidden) { log.Info("ApiHelper.UploadToDocuments() EMailIN folder '{0}' is unreachable. Try to unlink EMailIN...", mailbox.EMailInFolder); SetMailboxEmailInFolder(mailbox.TenantId, mailbox.UserId, mailbox.MailBoxId, null); mailbox.EMailInFolder = null; CreateUploadToDocumentsFailureAlert(mailbox.TenantId, mailbox.UserId, mailbox.MailBoxId, (ex.StatusCode == HttpStatusCode.NotFound) ? UploadToDocumentsErrorType .FolderNotFound : UploadToDocumentsErrorType .AccessDenied); throw; } log.Error("SaveEmailInData->ApiHelper.UploadToDocuments(fileName: '{0}', folderId: {1}) Exception:\r\n{2}\r\n", file.FileName, mailbox.EMailInFolder, ex.ToString()); } }
public static AttachmentStream GetAttachmentStream(MailAttachment attachment) { if (attachment != null) { var storage = MailDataStore.GetDataStore(attachment.tenant); var attachment_path = MailStoragePathCombiner.GerStoredFilePath(attachment); var result = new AttachmentStream { FileStream = storage.GetReadStream("", attachment_path), FileName = attachment.fileName }; return result; } throw new InvalidOperationException("Attachment not found"); }
public static AttachmentStream GetAttachmentStream(MailAttachment attachment) { if (attachment != null) { var storage = MailDataStore.GetDataStore(attachment.tenant); var attachmentPath = MailStoragePathCombiner.GerStoredFilePath(attachment); var result = new AttachmentStream { FileStream = storage.GetReadStream("", attachmentPath), FileName = attachment.fileName }; return(result); } throw new InvalidOperationException("Attachment not found"); }