Tag: Gmail中的API

如何使用Gmail Api获取邮件列表?

我想访问消息列表 宾语: 2.0.0-p481 :008 > g.gmail_api.users.messages.list => # 我是这个API的新手,无法了解如何使用Gmail API。 谢谢

使用ruby gmail api v0.9发送电子邮件

有没有人有一个简单的例子,说明如何使用v0.9 API从头开始发送电子邮件。 只想要一个发送以下内容的例子: m = Mail.new( to: “test1@test.com”, from: “test2@test.com”, subject: “Test Subject”, body:”Test Body”) 现在要创建需要发送的消息对象,我们可以使用: msg = Base64.urlsafe_encode64 m.to_s 然后尝试发送(其中message_object = msg): client = Google::Apis::GmailV1::GmailService.new #Appropriately authorised client.send_user_message(“me”, message_object) 客户端需要RFC822兼容的编码字符串,以上应该是。 我试过了: message_object = msg => Google::Apis::ClientError: invalidArgument: ‘raw’ RFC822 payload message string or uploading message via /upload/* URL required message_object = raw:msg =>ArgumentError: unknown […]

通过Gmail API创建包含收件人的Gmail草稿

我一直试图弄清楚如何自动将收件人添加到使用Gmail API通过其Ruby库创建的草稿电子邮件中。 我可以创建草案而没有任何问题,但设置收件人会给我带来麻烦,我无法找到任何好的示例,显示添加电子邮件特定事物的最佳方法。 使用Google API游乐场并提取已经创建的草稿,看起来结构应该与下面显示的类似,但是无论何时创建草稿,都没有收件人。 @result = client.execute( :api_method => gmail.users.drafts.create, :parameters => { ‘userId’ => “me” }, :body_object => { ‘message’ => { ‘raw’ => Base64.urlsafe_encode64(‘Test Email Message’), ‘payload’ => { ‘headers’ => [ { ‘name’ => “To”, ‘value’ => “John Smith ” } ] } } } )

如何使用带有Ruby Google API客户端的Gmail API发送消息?

我面临着API的几个问题, 第一: 发送方法询问’id’(消息ID或线程ID)..但为什么? 我正在发送新消息,所以它不应该要求。 根据Gmail Api documnetation它的可选。 https://developers.google.com/gmail/api/v1/reference/users/messages/send ArgumentError: Missing required parameters: id. 第二: 即使在指定消息ID后,它也会返回此消息。 Your client has issued a malformed or illegal request. 码 require ‘mime’ include MIME msg = Mail.new msg.date = Time.now msg.subject = ‘This is important’ msg.headers.set(‘Priority’, ‘urgent’) msg.body = Text.new(‘hello, world!’, ‘plain’, ‘charset’ => ‘us-ascii’) msg.from = {‘hi@gmail.com’ => ‘Boss […]

通过Google Gmail API创建草稿

我正在尝试为登录用户创建草稿消息,但在运行以下内容时不断收到错误Missing draft message require ‘google/api_client’ client = Google::APIClient.new client.authorization.client_id = ENV[‘GOOGLE_CLIENT_ID’] client.authorization.client_secret = ENV[‘GOOGLE_CLIENT_SECRET’] client.authorization.grant_type = ‘refresh_token’ client.authorization.refresh_token = User.last.refresh_token token = client.authorization.fetch_access_token! gmail = client.discovered_api(‘gmail’, ‘v1’) params = { ‘userId’ => ‘me’, ‘draft’ => { ‘message’ => {‘raw’ => ‘test email’ } } } # { ‘userId’ => ‘me’, ‘message’ => {‘raw’ => ‘test […]