Exemplo n.º 1
0
    static void LoadAttachments(AttachmentCollection attachments, DocumentModel document)
    {
        var htmlSubtitle = "<hr><p style='font: bold 12px Calibri;'>Attachments:</p>";

        document.Content.End.LoadText(htmlSubtitle, LoadOptions.HtmlDefault);

        foreach (Attachment attachment in attachments.Where(
                     a => a.DispositionType == ContentDispositionType.Attachment &&
                     a.MimeEntity.ContentType.TopLevelType == "image"))
        {
            document.Content.End.InsertRange(
                new Paragraph(document, new Picture(document, attachment.Data)).Content);
        }
    }
Exemplo n.º 2
0
        private static async Task <List <EmailFileAttachment> > ConvertAttachmentCollection(AttachmentCollection attachmenCollection)
        {
            var emailFileAttachments = new EditableList <EmailFileAttachment>();

            var fileAttachments = attachmenCollection.Where(attachment => attachment is FileAttachment);

            foreach (var fileAttachment in fileAttachments)
            {
                var emailFileAttachment = await ExchangeHandler.ConvertFileAttachment(fileAttachment as FileAttachment);

                emailFileAttachments.Add(emailFileAttachment);
            }

            return(emailFileAttachments);

            // return attachmenCollection.Where(attachment => attachment is FileAttachment).Select(async attachment => await ExchangeHandler.ConvertFileAttachment(attachment as FileAttachment)).ToList();
        }