【问题标题】:reply to thread google-api-ruby-client回复线程 google-api-ruby-client
【发布时间】:2017-09-05 20:14:46
【问题描述】:

这就是我的代码(几乎)使用 google-api-ruby-client 创建消息的样子:

  service ||= Google::Apis::GmailV1::GmailService.new

  message = RMail::Message.new
  message.header['To'] = params[:gmail][:to]
  message.header['From'] = current_user_google_user_id
  message.header['Subject'] = params[:gmail][:subject]
  message.header['Subject'] = params[:gmail][:subject]
  message.body = params[:gmail][:body]

  service.send_user_message(
    current_user_google_user_id,
    upload_source: StringIO.new(message.to_s),
    content_type: 'message/rfc822',
    thread_id: params[:gmail][:thread_id]
  )

它显然失败了,因为我有thread_id。如果我删除那条线,一切正常,但我无法将事情限制在一个线程中。我应该如何将线程 ID 传递给 GmailService?

【问题讨论】:

    标签: ruby gmail gmail-api


    【解决方案1】:

    在 GitHub 上查看 send_user_message 的源代码表明它没有将 thread_id 作为参数。但是Message class 确实将其作为属性。

    所以也许尝试这个应该可行:

      service ||= Google::Apis::GmailV1::GmailService.new
    
      message = RMail::Message.new
      message.header['To'] = params[:gmail][:to]
      message.header['From'] = current_user_google_user_id
      message.header['Subject'] = params[:gmail][:subject]
      message.header['Subject'] = params[:gmail][:subject]
      message.body = params[:gmail][:body]
      message.thread_id = params[:gmail][:thread_id]
    
      service.send_user_message(
        current_user_google_user_id,
        upload_source: StringIO.new(message.to_s),
        content_type: 'message/rfc822'
      )
    

    【讨论】:

    • 我已经换了一个不同的 gem,但这基本上是我想出来的。
    • 如何回复但使用 Mail:Message 对象?我无法在我的 Mail:Message 对象中添加 thread_id 参数
    猜你喜欢
    • 1970-01-01
    • 2011-07-01
    • 2016-11-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多