private static void AddEMailAttachmentToMail(Attachment attachment, MailMessage mail) { string extension = MimeTypeRepository.Instance.GetExtensionFromMimeType(attachment.ContentType); var emailAttachment = new System.Net.Mail.Attachment(attachment.Content, attachment.Id + extension); mail.Attachments.Add(emailAttachment); }
/// <summary> /// Start uploading <see cref="Attachment"/> /// </summary> /// <param name="attachment"></param> private void SendAttachmentAsMail(Attachment attachment) { var mail = new MailMessage(); var smtpServer = new SmtpClient(_config.GetSetting("smtpserver")); AddCommonInfoToMailMessage(mail); AddEMailAttachmentToMail(attachment, mail); AddSecurityToSmtpServer(smtpServer); smtpServer.Send(mail); LogUploadInformation(attachment); }
/// <inheritdoc /> public Task <UploadResult> UploadAsync(Attachment attachment, MessageInfo referringUserMessage) { if (attachment == null) { throw new ArgumentNullException(nameof(attachment)); } if (referringUserMessage == null) { throw new ArgumentNullException(nameof(referringUserMessage)); } SendAttachmentAsMail(attachment); return(Task.FromResult(UploadResult.SuccessWithId(payloadId: attachment.Id))); }
private void LogUploadInformation(Attachment attachment) { string toEmailAddress = _method["to"]?.Value; Logger.Info($"Attachment {attachment.Id} is send as Mail Attachment to {toEmailAddress}"); }