Skip to content

Using accessors on gmail_draft #214

Description

@daren3d

The accessor functions gm_to(), gm_cc(), etc. are already defined for the class gmail_draft. I have discovered that gm_to() works as expected, but gm_cc(), gm_bcc() and gm_from() do not. The first two return the from, and the third returns NULL. For example,

mime <- gm_mime() |>
  gm_to("to@mail.com") |>
  gm_cc("cc@mail.com") |>
  gm_bcc("bcc@mail.com") |>
  gm_from("from@mail.com") |>
  gm_subject("subject") |>
  gm_text_body("text body")
gm_create_draft(mime)
draft <- gm_draft(<id>)
# the following work
gm_to(draft) == gm_to(mime)
gm_subject(draft)
gm_body(draft)
# the following do not
gm_cc(draft) != gm_cc(mime)
gm_bcc(draft) == gm_from(mime)
gm_from(draft)

I looked inside of gmailr.R and I think the functions should be:

gm_from.gmail_draft <- function(x, ...) {
  gm_from.gmail_message(x$message, ...)
}
gm_cc.gmail_draft <- function(x, ...) {
  gm_cc.gmail_message(x$message, ...)
}
gm_bcc.gmail_draft <- function(x, ...) {
  gm_bcc.gmail_message(x$message, ...)
}

Have a great day!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions