在我的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发送电子邮件之前标记电子邮件?可能吗?我应该使用另一个库来实现这个目标吗?
答案 0 :(得分:1)
我从未使用过Gmail API,但IMAP协议有keywords
。您可以通过mail gem使用它,如下所示:
message = Mail.new do
to 'test@test.com'
from 'test@test.com'
keywords 'keyword, "another keyword"'
end