Exemple #1
0
        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);
        }
Exemple #2
0
        /// <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);
        }
Exemple #3
0
        /// <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)));
        }
Exemple #4
0
        private void LogUploadInformation(Attachment attachment)
        {
            string toEmailAddress = _method["to"]?.Value;

            Logger.Info($"Attachment {attachment.Id} is send as Mail Attachment to {toEmailAddress}");
        }