回复主题google-api-ruby-client [英] reply to thread google-api-ruby-client

查看:95
本文介绍了回复主题google-api-ruby-client的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 <$ c $这是我的代码(非常多)看起来像使用google-api-ruby-client创建消息: c> 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?

解决方案

在GitHub上查看 send_user_message 显示它不会将 thread_id 作为参数。但是, Message class 确实是它的一个属性。



p>

 服务|| = 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'


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?

解决方案

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆