Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Created April 15, 2025 11:31
Show Gist options
  • Save aspose-com-gists/f46c6ab786eb5c9bf009c29d9625b555 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/f46c6ab786eb5c9bf009c29d9625b555 to your computer and use it in GitHub Desktop.
Managing Reference Attachments in MSG Files Using C#
var options = new ReferenceAttachmentOptions(
"https://drive.google.com/file/d/1HJ-M3F2qq1oRrTZ2GZhUdErJNy2CT3DF/", // Attachment URL
"https://drive.google.com/drive/my-drive", // Provider link
"GoogleDrive" // Provider type
);
// Add reference attachment
msg.Attachments.Add("Document.pdf", options);
var msg = MapiMessage.Load(@"message.msg");
foreach (var attachment in msg.Attachments)
{
if (attachment.IsReference)
{
// Process reference attachment
}
}
var msg = MapiMessage.Load(@"message.msg");
foreach (var attachment in msg.Attachments)
{
if (attachment.IsReference)
{
var originalUrl = attachment.GetProperty(KnownPropertyList.AttachmentOriginalUrl).GetString();
var providerType = attachment.GetProperty(KnownPropertyList.AttachmentProviderType).GetString();
var longPathname = attachment.GetProperty(KnownPropertyList.AttachLongPathname).GetString();
var attachMethod = attachment.GetProperty(KnownPropertyList.AttachMethod).GetLong();
Console.WriteLine($"Original URL: {originalUrl}");
Console.WriteLine($"Provider Type: {providerType}");
Console.WriteLine($"Long Pathname: {longPathname}");
Console.WriteLine($"Attach Method: {attachMethod}");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment