回复线程 google-api-ruby-client [英] reply to thread google-api-ruby-client
问题描述
这就是我的代码(几乎)使用 google-api-ruby-client 创建消息的样子:
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]
)
它显然失败了,因为我有 thread_id
.如果我删除那条线,一切正常,但我无法将事情限制在一个线程中.我应该如何将线程 ID 传递给 GmailService?
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?
推荐答案
在 GitHub 上查看源代码 send_user_message
表明它不需要 thread_id
作为参数.但是 Message
类 确实有它作为属性.
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'
)
这篇关于回复线程 google-api-ruby-client的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!