I am using a service account and domain wide delegation to access all email accounts under client's domain with read-only scope https://www.googleapis.com/auth/gmail.readonly In the message get request I use format option "metadata" with fields='payload/headers' which returns only email headers but not the content of the message.
Is there a way to restrict my app access to metadata only and not the content of the emails? This would ensure that my application can not read sensitive email content information and have access to metadata only.
Thanks!
The Gmail API now (as of November 2016) does support a gmail.metadata scope!
C.f.
https://developers.google.com/gmail/api/auth/scopes
It allows access to email headers, including subject, without email message data. Calls to message.get() with format=METADATA and format=MINIMAL will work with that scope, but not, for example, format=FULL or format=RAW.
Set your scope to https://www.googleapis.com/auth/gmail.metadata.
See https://developers.google.com/gmail/api/auth/scopes
https://www.googleapis.com/auth/gmail.metadata
Read resources metadata including labels, history records, and email message headers, but not the message body or attachments
You can get only the specified headers via specifying 'format'=>'metadata' and 'metadataHeaders'=>array(headers you want to receive, excluding others). Check a sample get request in PHP below:
$service->users_messages->get($userId, $message->id,array('format'=>'metadata', 'metadataHeaders'=>array('From','To')));
The above code will only get From and To headers and wont show Subject header.
Hope this helps.
Related
I understand that to use the /attachments API, an id of the event or message which has an attachment needs to be passed. Can attachment data for an event or message be obtained without this dependency? For example, when I'm making a call to /events API for a particular user, along with events data for that user, can I also get attachment data associated with the event?
I'm using client credentials flow.
This is possible by explicitly specifying that you'd like to include attachments the response body using the OData expand query option.
In your case, the request URI would look as follows: https://graph.microsoft.com/v1.0/me/events?$expand=attachments
I followed this documentation to download the attachments of email.
Below is the API response.
If email attachment type is FileAttachment, I am able to get the file content in api response and able to save the attachment.
If email attachment type is ItemAttachment, I am not able to get the file content in api response. When I googled for it, I found this stack overflow question. I used the rest API mentioned in the answer. But it's giving itemAttachment content in html format. And if that ItemAttachment has any fileattachment in it, then I am unable to access it.
Is there any API available to download the itemAttachment as .eml file not as html?
Any suggestion/answers would be more than welcome.
I assume by .eml you mean you'd like to retrieve the email in MIME format?
Retrieving an email's raw MIME content isn't supported by Microsoft Graph API at this time. This has been a common request and there is an existing UserVoice request for it.
If this is a hard requirement for your scenario, you may want to take a look at Exchange Web Services (EWS). The Message object returned by EWS includes a MimeContent property.
This is now supported on https://outlook.office365.com/api/v2.0/me/messages/<Message-Id>/$value endpoint
I'm building a Ruby on Rails app, and I'd like to integrate some Office365 features.
For instance : I would like to download a file from OneDrive and then attach it to an Email in order to send it via Outlook rest API.
I found this get Item content OneDrive REST API but I dont understand how to use it.
I understand that I have to send a GET request (formated as explained in msdn.microsoft.com) with Rails, which will then provide me a "a pre-authenticated download URL" to download the file.
Then I will have to send a second GET request with this a pre-authenticated download URL to start the download, but I don't understand how to deal with the Response in order to save the file into a variable.
How can I retrieve the file into a variable of my Ruby on Rails App, so that I can attach it to an Email with an Outlook REST API to send it from my own Rail controller ?
Also this workflow is really not optimized in term of Bandwidth and Processing (3 REST API request + 1 download + 1 upload), it will work.
However if it exist a single REST API that direclty attach a OneDrive file to an email to send it, that would ease a lot my life, save energy, save money from Microsoft datacenter, and spare the planet ecology.
Any tutorial, examples, or more explanatory doc would be much appreciated.
--- EDIT ---
Adding link to the email is not wished as the email may have to be send to someone outside of Office365 users, and public link are a security issue for confidential documents.
Any help is welcome.
There isn't a single REST API call you can make currently to do what you want, although being able to easily attach a file from OneDrive to a new email message is a great scenario for Microsoft Graph API, it just isn't supported right now.
If you want to attach the file, you need to do as you mentioned, download the contents of the file, and then upload it again as an attachment to the message.
However, I'd recommend sending a link to the file instead, even though you mentioned you don't want to do that. OneDrive for Business now supports "company shareable links" which are scoped to just the user's organization instead of being available totally anonymously.
Something else to consider: The security concerns of sending an anonymous link aren't that different than sending an attached file. In fact, the anonymous link can be more secure, because access to the file can be monitored and revoked in the future (unlike the attachment, which will always be out there).
I have situation that if anyone send SMS to my virtual number(CallerID) the BurstSMS API will call my handler which get the response from query string and proceed further.
So, I want to know only that ,how and which things needed to integrate the BurstSMS API in my APS.NET application.
I couldn't find the information from the documentation of API site and as well as not any article on the google.
Thanks in advance.
This is what you need to do.
Log in to your account
Go to Messaging -> Keywords
Click Edit from the Actions column of the campaign you would like to receive responses for
In the form which pops up fill in the "Send Response to URL" field with a URL to a script on your server which can process the responses, e.g. www.clienturl.com/sms.php
Click Save
From then on we will forward all SMSes for that campaign to your script with an HTTP GET request. For example, if you send "Property 25" to your longcode, we will call
www.clienturl.com/sms.php?mobile=61430008230&response=Property+25
From that you can see the parameters we use.
You could also add other parameters your own reference such as the longcode or an internal client id by using a different URL in the "Send Response to URL" field, e.g.
www.clienturl.com/sms.php?longcode=61418499440&client=123
In which case we would send to you
www.clienturl.com/sms.php?longcode=61418499440&client=123&mobile=61430008230&response=Property+25
Source burstsms
Right now my app sends out email notifications. I'd like to allow the user to reply directly to the email, which then gets ingested by my app and inserted into the database.
Are there any Rails gems, services, tutorials that can point me in the right direction.
Also, probably need to make the reply-to email have a UID, replyto--UID#domain.com, so I don't have to rely on the from (sender).
What do you think?
Thanks
A few good articles to get you started:
http://railstips.org/blog/archives/2008/10/27/using-gmail-with-imap-to-receive-email-in-rails/
http://jasonseifer.com/2009/04/24/receving-email-with-rails
We have a free service that posts incoming email to a url of your application (same as sendgrid API):
http://www.smtp2web.com
You can also use the mailman gem if you want to poll for the email at regular intervals:
https://github.com/titanous/mailman
As far as the 'replyto--UID#domain.com' kind of email addresses are concerned, you will have to create a catch-all address for your domain (it is better if you use a obscure subdomain, as it would reduce the amount of spam) which forwards all such email to a given mailbox(say notifications#domain.com).
I would highly recommend using CloudMailin for the same.
It provides you a receiving email address, which you can add as a reply-to header in your mail.
About the unique UID, for tracking each reply in context of the sent email, you could generate a random string, and modify your reply-to header as "[email provided by cloudmailin]+[your random string]"
You'd need to look at configuring your sendmail/postfix to accept incoming mail first off ( if you're using unix based server ).
Heres a good article:
http://jasonseifer.com/2009/04/24/receving-email-with-rails
You can use Sendgrid to parse incoming email and have it send along to your app via a web-post.
This is a decent tutorial (heroku focused)
Or you can view Sendgrid's ParseAPI to see how to integrate.