如何使用Google API客户端发送电子邮件

时间:2019-02-04 05:34:05

标签: ruby-on-rails google-api-client

我是Ruby的新手,并且正在使用Google API。我正在尝试使用以下代码发送电子邮件:

msg = Mail.new
msg.date = Time.now
msg.subject = 'Testing'
msg.body = '<p>Hi Alex, hows life?</p>'
msg.from = self.email
msg.to   = 'fakeemail@gmail.com'

@email = @google_api_client.execute(
    api_method: @gmail.users.messages.to_h['gmail.users.messages.send'],
    body_object: {
        raw: Base64.urlsafe_encode64(msg.to_s)
    },
    parameters: {
        userId: 'me',
    }
)

但是,我遇到此错误:

uninitialized constant Mail (NameError)

有人可以告诉我我在做什么错吗?

0 个答案:

没有答案