Skip to content

fix: Honor ContentType parameter for FilePath-based linked resources#56

Merged
nfMalde merged 2 commits intofeature/cid-supportfrom
copilot/sub-pr-54-again
Jan 4, 2026
Merged

fix: Honor ContentType parameter for FilePath-based linked resources#56
nfMalde merged 2 commits intofeature/cid-supportfrom
copilot/sub-pr-54-again

Conversation

Copy link
Contributor

Copilot AI commented Jan 4, 2026

When calling AddLinkedResource(string filePath, string contentType, string contentId, string? fileName = null), the contentType parameter was stored but ignored during MIME message construction, causing linked resources to always use auto-detected content types.

Changes

  • MailClient.cs: FilePath-based linked resources now read file as bytes and pass explicit contentType to bodyBuilder.LinkedResources.Add(), matching the pattern used by FileUrl and FileBytes handlers
  • Falls back to MimeKit.MimeTypes.GetMimeType() when contentType is null

Example

// Content type is now properly applied instead of being ignored
context.Attachments.AddLinkedResource(
    "path/to/image.bin",  
    "image/png",           // This now takes effect
    "logo"
);

Previously, the image would be added with MIME type detected from .bin extension. Now it correctly uses image/png.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI self-assigned this Jan 4, 2026
Co-authored-by: nfMalde <5366984+nfMalde@users.noreply.github.com>
Copilot AI changed the title [WIP] Add CID support for inline images in email fix: Honor ContentType parameter for FilePath-based linked resources Jan 4, 2026
Copilot AI requested a review from nfMalde January 4, 2026 09:50
@nfMalde nfMalde marked this pull request as ready for review January 4, 2026 09:54
Copilot AI review requested due to automatic review settings January 4, 2026 09:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug where the contentType parameter was ignored when adding FilePath-based linked resources, causing them to always use auto-detected content types instead of the explicitly specified type.

Key Changes:

  • Modified FilePath-based linked resource handling to read file bytes and pass explicit content type to MimeKit
  • Aligned implementation with existing FileUrl and FileBytes handler patterns

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@nfMalde nfMalde merged commit 0376756 into feature/cid-support Jan 4, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants