【问题标题】:Labeling email on compose - Gmail - Rails在撰写上标记电子邮件 - Gmail - Rails
【发布时间】:2016-04-02 13:55:04
【问题描述】:

在我的 rails 应用程序中,我使用这个 gem 与 Gmail API 交互:https://github.com/gmailgem/gmail

这是我发送电子邮件的方法:

email_to = params[:email]
subject_to = params[:subject]

email = gmail.compose do
  to email_to
  subject subject_to
  body "Spent the day on the road..."
  label "Urgent"
end

email.deliver!

我收到此错误:

undefined method `label' for #<Mail::Message:0x007fb370e94cf8>

如何在使用此 gem 发送电子邮件之前为其添加标签?可能吗?我应该使用另一个库来实现这一点吗?

【问题讨论】:

    标签: ruby-on-rails ruby


    【解决方案1】:

    我从未使用过 Gmail API,但 IMAP 协议有 keywords。您可以像这样通过mail gem 使用它:

    message = Mail.new do
      to 'test@test.com'
      from 'test@test.com'
      keywords 'keyword, "another keyword"'
    end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-01-20
      • 2016-09-02
      • 1970-01-01
      • 2014-05-26
      • 1970-01-01
      • 1970-01-01
      • 2020-03-28
      • 1970-01-01
      相关资源
      最近更新 更多