Created
August 17, 2022 08:51
-
-
Save conholdate-docs-gists/8d35af233888670be397eb4f95964c7a to your computer and use it in GitHub Desktop.
Add watermark to emails in c# | https://docs.conholdate.com/net/add-watermarks-to-emails/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TextWatermark watermark = new TextWatermark("Test watermark", new Font("Arial", 19)); | |
EmailLoadOptions loadOptions = new EmailLoadOptions(); | |
// Constants.InMessageMsg is an absolute or relative path to your document. Ex: @"C:\Docs\message.msg" | |
using (Watermarker watermarker = new Watermarker(Constants.InMessageMsg, loadOptions)) | |
{ | |
EmailContent content = watermarker.GetContent<EmailContent>(); | |
foreach (EmailAttachment attachment in content.Attachments) | |
{ | |
// Check if the attached file is supported by GroupDocs.Watermark | |
IDocumentInfo info = attachment.GetDocumentInfo(); | |
if (info.FileType != FileType.Unknown && !info.IsEncrypted) | |
{ | |
// Load the attached document | |
using (Watermarker attachedWatermarker = attachment.CreateWatermarker()) | |
{ | |
// Add wateramrk | |
attachedWatermarker.Add(watermark); | |
// Save changes in the attached file | |
attachedWatermarker.Save(); | |
} | |
} | |
} | |
// Save changes | |
watermarker.Save(Constants.OutMessageMsg); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Read the complete article: https://docs.conholdate.com/net/add-watermarks-to-emails/