Skip to content

feat: Add Content-Id mapping to AzureEmailSender & GraphSender for inline attachments #40

@lylezhan

Description

@lylezhan

I have encountered an issue when using the AzureEmailSender and GraphSender classes to send emails with inline attachments.
Unfortunately, it appears that this method is ineffective.

Could you please add a mapping for the Content-Id to resolve this issue?

// GraphSender.cs
if (email.Data.Attachments != null && email.Data.Attachments.Count > 0)
{
    message.Attachments = new MessageAttachmentsCollectionPage();

    email.Data.Attachments.ForEach(a =>
    {
        var attachment = new FileAttachment
        {
            Name = a.Filename,
            ContentType = a.ContentType,
            ContentBytes = GetAttachmentBytes(a.Data),
            IsInline = a.IsInline,
            ContentId = a.ContentId
        };

        message.Attachments.Add(attachment);
    });
}
//AzureEmailSender.cs
private async Task<EmailAttachment> ConvertAttachment(FluentEmail.Core.Models.Attachment attachment) =>
    new(attachment.Filename, attachment.ContentType, await BinaryData.FromStreamAsync(attachment.Data)) { ContentId = attachment.ContentId };

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions