private static Attachment GetAttachment(EmailEmbeddedResource embeddedResource) { Attachment attachment = new Attachment(embeddedResource.Content, embeddedResource.FileName); attachment.ContentDisposition.Inline = true; return(attachment); }
private static AlternateView GetEmbeddedImage(EmailEmbeddedResource embeddedResource, ref string htmlBodyEmail) { LinkedResource resource = new LinkedResource(embeddedResource.Content); string htmlBody = string.Empty; if (embeddedResource.Type == EmailEmbeddedResourceType.IMAGE) { resource = new LinkedResource(embeddedResource.Content, Image.Jpeg); if (!string.IsNullOrEmpty(htmlBodyEmail.Trim())) { htmlBody = htmlBodyEmail.Replace(string.Format("<img src=\"cid:{0}\"", embeddedResource.Name), string.Format("<img src=\"cid:{0}\"", embeddedResource.GuidId)); htmlBodyEmail = htmlBody; } else { htmlBody = string.Format("<img src=\"cid:{0}\">", embeddedResource.GuidId); } } resource.ContentId = embeddedResource.GuidId; AlternateView alternateView = AlternateView.CreateAlternateViewFromString(htmlBody, null, Text.Html); alternateView.LinkedResources.Add(resource); return(alternateView); }