Send Outlook email from template file via Graph API - office365api

How can I send email based on Outlook template file (.oft) using Graph API?
I tried example 4 in: Microsoft Docs
where I converted .oft file content to base64, but it didn't work. Could somebody advise how to create a proper MIME format or is there an easier way?

Related

Using MS Graph API is it possible to just list the email attachments without downloading the its content?

We're using MS Graph API to get the list of emails from an Outlook 365 mailbox. We have a requirement to list the attachments in every email.
When using the List Attachments endpoint of the Graph API, the contentBytes attribute value in the response contains the entire Base64 encoded attachment content. This increases the response size significantly. We have no need to access or store the attachment content.
https://learn.microsoft.com/en-us/graph/api/message-list-attachments?view=graph-rest-1.0&tabs=http#example
Is there a way in MS Graph API to just get the attachment file name(s) and IDs for one or more email messages?
Yes, you can use the same /attachments endpoint and get only the id and name of attachment using the $select query parameter.
Simply use the query
https://graph.microsoft.com/v1.0/me/messages/{messageid}/attachments?$select=id,name
Result:
You can always test graph calls in Graph Explore.

Outlook Rest API: Download the email attachments of type .eml files using outlook rest API

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

Search result on bases of file name using Microsoft graph api

I am using Microsoft Graph API for OneDrive (personal and business) integration. I am able to get content using the Search API but it is not returning the results expected per the documentation.
I have also compared response using Microsoft Graph Explorer with same request.
I am using these api requests:
GET /me/drive/search(q='doc') when searching on root.
GET /me/drive/root:/{item-path}:/search(q='{search-text}') when searching on non-root folder
These calls are not returning all of the files I would expect. I am not able to files which are 0 byte (empty).
search not return specific type of files, like .png, .jpg,.md,.js, maybe even more. for my testing, it will return .pdf, docx, odp and xls

How can I download a OneDrive file with Office365 REST API into a Ruby variable?

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).

EBAY - Sending a file via http post?

I've a file I want to send to the ebay system to support the LMS.
All the samples I've found include the use of the API, but the environment I'm working in doesn't have the ability to use it (the api).
So I'm forced to send the file with an HTTP post. But the doc's seem lacking.
Has anyone constructed/found an example of a HTTP post that will send a given file.
EDIT:
Oh.. what I see in the samples I have found is an area that seems it's supposed to have the data, but in the sample, there's nothing I'd consider real data.
Are you talking about the file transfer service or the bulk upload service? Don't you just generate an xml document and post the url like in this example:
http://developer.ebay.com/DevZone/file-transfer/CallRef/uploadFile.html#Samples

Resources