andrie/mailmerge

msg gets overwritten

Closed this issue · 1 comments

The last time I used this package in March, I had no issues and it worked great!

Today, I was getting the following error when I tried to send as a draft or immediately (but not for preview):
Error in message$body : $ operator is invalid for atomic vectors

I think the issue is the confirmation message in mail_merge() because msg gets overwritten when it is not a preview.

msg <- mm_read_message(message)
if(!preview && !confirm) {
    msg <- paste0("Send ", nrow(data), " emails (", send, ")?")
    cat(msg)
    if (yesno()) {
      return(invisible())
    }
  }

I've never done a pull request, but it works fine if you change the code to.

msg <- mm_read_message(message)
if(!preview && !confirm) {
    confirmmsg <- paste0("Send ", nrow(data), " emails (", send, ")?")
    cat(confirmmsg)
    if (yesno()) {
      return(invisible())
    }
  }

Fixed in #10

Thank you for identifying the issue and proposing the fix.