reply to thread google-api-ruby-client

落花浮王杯 提交于 2019-12-04 06:33:25

问题


So here's what my code (pretty much) looks like to create a message using the 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]
  )

It obviously fails because of where I have thread_id. If I remove that line, things work fine, but I'm not able to keep things scoped to a thread. How should I be passing the thread ID to the GmailService?


回答1:


Looking at the source on GitHub for send_user_message shows that it doesn't take a thread_id as a parameter. However the Message class does have it as an attribute.

So perhaps trying this should work:

  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'
  )


来源:https://stackoverflow.com/questions/43329035/reply-to-thread-google-api-ruby-client

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!