Skip to content

Conversation

@jennybc
Copy link
Member

@jennybc jennybc commented Nov 4, 2025

Fixes #202

@jennybc
Copy link
Member Author

jennybc commented Nov 4, 2025

Good manual tests (but, yes, actual tests have been added as well):

# Pick one, depending on your situation
#library(gmailr)
devtools::load_all()

# Do you need to authenticate?
# Not necessary when I do `load_all()` as it uses existing token
# gm_auth()

# Test 1: Text + HTML + PDF attachment (send as draft)
# This was one of the original reported scenarios
message1 <- gm_mime() |>
  gm_to("jenny+gmailr-tests@posit.co") |>
  gm_subject("Test 1: Text+HTML+PDF - Issue #202") |>
  gm_text_body("This is the plain text body.") |>
  gm_html_body(
    "<p>This is the <strong>HTML</strong> body.</p>"
  ) |>
  gm_attach_file(R.home('doc/html/Rlogo.pdf'))

# Create draft (don't send yet - look at the draft first)
draft1 <- gm_create_draft(message1)

# Now send it and check what you received
gm_send_draft(draft1)

# Test 2: Text + HTML + TXT attachment (send directly)
# This was the other main scenario from the issue
message2 <- gm_mime() |>
  gm_to("jenny+gmailr-tests@posit.co") |>
  gm_subject("Test 2: Text+HTML+TXT - Issue #202") |>
  gm_text_body("Plain text body for text attachment test.") |>
  gm_html_body("<p><em>HTML body</em> for text attachment test.</p>") |>
  gm_attach_file(system.file("DESCRIPTION"), type = "text/plain")

# Send directly
gm_send_message(message2)

# Test 3: Multiple attachments (send as draft)
# Verify the fix works with multiple attachments
message3 <- gm_mime() |>
  gm_to("jenny+gmailr-tests@posit.co") |>
  gm_subject("Test 3: Text+HTML+Multiple attachments - Issue #202") |>
  gm_text_body("Testing with multiple attachments (plain text).") |>
  gm_html_body(
    "<p>Testing with <strong>multiple attachments</strong> (HTML).</p>"
  ) |>
  gm_attach_file(R.home('doc/html/Rlogo.pdf')) |>
  gm_attach_file(R.home('doc/html/logo.jpg'))

draft3 <- gm_create_draft(message3)
gm_send_draft(draft3)

@jennybc jennybc merged commit 97df629 into main Nov 4, 2025
15 checks passed
@jennybc jennybc deleted the nested-mime branch November 5, 2025 00:39
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.

Cannot send messages with .txt or .pdf attachments when body is text+html: gm_send_message() and gm_send_draft() are dropping some MIME parts

2 participants