Skip to content

Allow sending a message from MIME content and setting its MessageDisposition - #306

Merged
pcai merged 1 commit into
WinRb:mainfrom
Mailbutler:upstream-mime-content
Nov 7, 2026
Merged

pcai merged 1 commit into
WinRb:mainfrom
Mailbutler:upstream-mime-content

Conversation

@fjaeger

@fjaeger fjaeger commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

What kind of change is this?

Feature, plus a bugfix in the SOAP builder.

Did you add tests for your changes?

Yes: spec/unit/templates/message_spec.rb (new) and two examples in spec/unit/soap/builders/ews_builder_spec.rb. bundle exec rspec and bundle exec rubocop pass locally.

Summary of changes

We send and schedule mail through EWS from a raw RFC 822 message, so we need CreateItem with t:MimeContent instead of subject/body/recipients. We have run this from a fork since 2023 and would like to stop.

  • Template::Message accepts mime_content (Base64-encoded MIME) and an optional mime_content_charset (default UTF-8). It is emitted as t:MimeContent with a CharacterSet attribute.
  • Template::Message accepts an explicit message_disposition (SaveOnly, SendOnly, SendAndSaveCopy). Without one, it still derives it from draft, as before.
  • Builder fix: EwsBuilder#mime_content! used to emit t:IncludeMimeContent (for item shapes). Item hashes are built with send("#{key}!", value), so a mime_content key in a Message, CalendarItem or Task hash (CalendarItem/Task templates already list mime_content in PARAMETERS) produced the wrong element. The item-shape helper is renamed to include_mime_content! and mime_content! now builds t:MimeContent.

Example:

client.draft_message do |m|
  m.mime_content = Base64.strict_encode64(raw_rfc822)
  m.saved_item_folder_id = folder_id
end

Other information

mime_content! is a public builder method, so callers that invoked it directly to build IncludeMimeContent need include_mime_content! now. item_shape! was the only caller in the gem. Happy to keep a deprecated alias or take a different approach if you prefer.

…osition

Template::Message now accepts `mime_content` (Base64-encoded MIME) plus an
optional `mime_content_charset` (default UTF-8), and an explicit
`message_disposition` that overrides the draft-derived default.

The builder's `mime_content!` used to emit `IncludeMimeContent`, so a
`mime_content` key in an item hash (Message, CalendarItem, Task) produced
the wrong element. It is renamed to `include_mime_content!` and
`mime_content!` now builds `t:MimeContent` with its CharacterSet.
@pcai
pcai merged commit 4c263e3 into WinRb:main Nov 7, 2026
15 checks passed
@pcai

pcai commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

@fjaeger thank you

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