gmail-api

Can't open downloaded attachments from Gmail API

笑着哭i 提交于 2019-12-02 02:18:12
I feel like I'm missing something stupid... I'm using the PHP SDK for the new Gmail API to fetch an attachment from an email. I can get the attachment content, but unless it's a text file, I can't open the file after it's been saved. If the attachment is a PDF, it won't render. If it's an excel file, it won't open. What am I doing wrong? // this works; I get the attachment body, etc $data = $g->gmail->users_messages_attachments->get($email_account, $email_message_id, $p->getBody()->getAttachmentId()); $fh = fopen(DOC_ROOT."/file.pdf", "w+"); fwrite($fh, base64_decode($data->data)); fclose($fh)

How to get the number of unread threads in INBOX with Gmail API?

依然范特西╮ 提交于 2019-12-01 22:05:00
问题 I tried to use the list thread method: GET https://www.googleapis.com/gmail/v1/users/{MyEmailAddress}/threads?labelIds=INBOX&labelIds=UNREAD&key={YOUR_API_KEY} The resultSizeEstimate does not match the number next to my inbox in Gmail web app. Is there another way? 回答1: The Gmail API now provides total and unread counts for messages and threads on each Label using the Labels.Get() method. See: https://developers.google.com/gmail/api/release-notes and https://developers.google.com/gmail/api/v1

Attaching a file using Resumable upload w/ Gmail API

空扰寡人 提交于 2019-12-01 21:32:22
I am attempting to use Gmail's Resumable option for uploading attachments to an email. Documentation reference: https://developers.google.com/gmail/api/guides/uploads#resumable . Currently I am able to send the email with the resumable URI, but without an attachment (using Postman). Documentation doesn't provide very clear examples of what the request should specifically look like, and there don't seem to be many examples after scouring the internet. My requests are in two parts: Initial request - Request URL: POST /upload/gmail/v1/users/me/messages/send?uploadType=resumable Host: www

watch request to new topic pauses push notifications to existing topic

寵の児 提交于 2019-12-01 21:26:33
I've configured two topics in my Google Cloud Pub/Sub account, each with a single subscription, under a single project. When I call watch() on my inbox, passing topic 1 to the watch request, I receive push notifications to my desired endpoint. When I call watch() on my inbox for topic 2 , I receive push notifications for the endpoint tied to topic 2, but push notifications stop arriving for topic 1 . It appears that only a single topic can push out notifications for a given inbox at any given time, for a given project. Can anyone help confirm whether this is the case? I can't find anything in

How to get the number of unread threads in INBOX with Gmail API?

折月煮酒 提交于 2019-12-01 20:18:37
I tried to use the list thread method: GET https://www.googleapis.com/gmail/v1/users/{MyEmailAddress}/threads?labelIds=INBOX&labelIds=UNREAD&key={YOUR_API_KEY} The resultSizeEstimate does not match the number next to my inbox in Gmail web app. Is there another way? The Gmail API now provides total and unread counts for messages and threads on each Label using the Labels.Get() method. See: https://developers.google.com/gmail/api/release-notes and https://developers.google.com/gmail/api/v1/reference/users/labels Turn conversation view off in the Gmail UI in order to get an accurate count of the

Watch request in gmail API doesn't work

血红的双手。 提交于 2019-12-01 19:56:59
I am trying to make a watch request using python as referred to in the google APIs but it does not work. request = { 'labelIds': ['INBOX'], 'topicName': 'projects/myproject/topics/mytopic' } gmail.users().watch(userId='me', body=request).execute() I could not find a library or a package to use gmail.users() function. How do I make a watch request using an access token? Do it in gmail python client(provide by google).under main function request = { 'labelIds': ['INBOX'], 'topicName': 'projects/myprojects/topics/getTopic' } print(service.users().watch(userId='me', body=request).execute()) const

Gmail API not returning correct emails compared to Gmail web UI for date queries

本秂侑毒 提交于 2019-12-01 18:01:52
The results differ between the Gmail api and Gmail web ui when using the standard query format as described here - https://support.google.com/mail/answer/7190 . The issue is specifically for the parameters after/before and newer/older. For example the following Gmail api query "after:2015/11/19 before:2015/11/20" returns different results compared with running that same query in the Gmail web ui. The web ui looks correct whereas the api returns emails from the next day (20th). Possibly a timezone conversation problem? Checking past questions I see something similiar here how to use GMAIL API

“500 Backend Error” using Gmail API - safe to retry?

点点圈 提交于 2019-12-01 17:46:21
问题 I'm sending messages via the Gmail API. In particular, I am trying to send 5-7 emails from the same account to different users (1 each) within about 2 seconds. About 8% of those emails are failing with this error: &googleapi.Error{ Code:500, Message:"Backend Error", Body:`{ "error": { "errors": [ { "domain": "global", "reason": "backendError", "message": "Backend Error" } ], "code": 500, "message": "Backend Error" } }`, Header:http.Header(nil), Errors:[]googleapi.ErrorItem{ googleapi

GMail API : unable to add an attachment in a draft

不打扰是莪最后的温柔 提交于 2019-12-01 14:09:43
I am able to create simple html-only drafts using the GMail API. But when I try to upload attachments it fails with the following error : { "code" : 500, "errors" : [ { "domain" : "global", "message" : "Backend Error", "reason" : "backendError" } ], "message" : "Backend Error" } Here is my code, can anyone help me ? Properties props = new Properties(); Session session = Session.getDefaultInstance(props, null); MimeMessage email = new MimeMessage(session); InternetAddress tAddress = new InternetAddress("to@to.in"); InternetAddress fAddress = new InternetAddress("from@from.in"); email.setFrom

gmail with table in message body is not getting displayed in mail but table data is displayed

泪湿孤枕 提交于 2019-12-01 14:02:00
This is my actual output This is my expected output when a mail is sent with html table along with file attachment(like image, pdf, etc.), table format is not displayed in mail but content of table is displayed. But when I inspect mail body table is present. Problem is that its not shown in table format. But when mail sent with html table without attachment, table format is getting displayed in mail. How to fix it. let user = await db.model('User').findOne({ _id: userId }); let filepath = fs.readFileSync(req.file.path).toString('base64'); let from = user.crmOptions.email; let raw = [ 'MIME