Unable to add image to Outlook Online - outlook-addin

I want to add an image to my mail body by Office.js but this is not working for Outlook Online.
I don't want my picture to be accessible for everyone so this is what I do (this works for Outlook Desktop):
Add an attachment by url
Office.context.mailbox.item.addFileAttachmentAsync(url, name,
{ isInline: true },
function (asyncResult) {
...
});
Add image to body
Office.context.mailbox.item.body.setSelectedDataAsync('<img src="cid:' + name + '">',
{ coercionType: Office.CoercionType.Html },
function (asyncResult) {
});
After the file is attached we remove the image so it isn't available anymore at the url.
How do I get adding file attachments to work for Outlook Online?

As I understood your issue, the recipients, as well as yourself is not able to see the photo that you've embedded on a email. Am I correct? The following are the possible reasons affecting the issue:
Possible that the file size of the picture maybe too large
A possible issue on recipients's end (browser issue)
Slow nternet connection
For more information, please refer to the link below:Unable to insert a photo in Outlook.com
Hopefully it helps you!

Related

Integromat - Google Calendar - How to add attachment to event with "Make an API call"

I would like to add attachment to Google calendar event with integromat "Make an API call" module. Attachment uploaded previously to Google drive.
I dont know how to setup the "MAKE an API call" module. See screenshot below.
I tried to understand the integromat help for this, but it was a little bit difficult for me.
If somebody have a scenario for this please help me.
Thanks for any help!
I am pretty sure that Google Calendar API doesn't support external files as part of the attachment, I might be wrong though. The current working scenario, that I shared will be able to add a Google Drive File as part of the attachment. Please refer the screenshot,
You will need to use following,
URL: /v3/calendars/{{CALENDAR_ID}}/events/{{EVENT_ID}}?supportsAttachments=true
Method: PATCH
Body :
{
"attachments": [{
"fileId" : "",
"fileUrl": "https://drive.google.com/file/d/1yyVVQxgwb7wF6RckN_1KoGtSmikjk2MR/view?usp=sharing",
"mimeType": "image/png",
"title": "TestImage.png"
}]
}
You can refer the document here : https://developers.google.com/calendar/api/v3/reference/events/patch

Is it possible to create a project documentset using graph API?

So far I haven't been able to find any information on how to create project documentsets on my Sharepoint environment using the Graph API. I've tried both Sharepoint's 'Create item' and OneDrive's 'Create Folder'. The Sharepoint API says:
"Files and folders should only be added to a DocumentLibrary via the OneDrive API"
The OneDrive API says:
"Either 'folder' or 'file' must be provided, but not both."
As you can tell from the responses, it seems limited to only having the options to create either a folder or a file. Is this correct? Is there any way to mutate a folder to a document set using a different API call?
I have tried to add the content type ID to the different request bodies, in every case providing no further solution.
Hope someone here knows a possible solution and can help me. Thanks!
I've dealt with the same issue today. I needed to create a Document Set in the root level of a Document Library after some business logic.
Here's how I've achieved to do so:
1- Get the document library's Drive Id:
GET https://graph.microsoft.com/v1.0/sites/${siteId}/lists/${listId}?$expand=drive
2- Create the folder:
POST https://graph.microsoft.com/v1.0/drives/${library.drive.id}/root/children
Remember to set the body as:
{
"name": ${nameOfTheFolder},
"folder": {},
}
3- Get the folder's SharePoint item id:
GET https://graph.microsoft.com/v1.0/sites/${siteId}/drives/${library.drive.id}/items/${folder.id}?expand=sharepointids
4- Update the item in the Document Library so that it updates to the desired Document Set:
PATCH https://graph.microsoft.com/v1.0/sites/${siteId}/lists/${listId}/items/${sharepointIds.listItemId}
Don't forget to set the body to:
{
"contentType": {
"id": "content-type-id-of-the-document-set"
},
"fields": {
//whatever fields you want to set
}
}
Hope it helps
I have been looking into this myself aswell and walked into the same wall.
At the moment, unfortunately, there is no combined method.
You can use them both to combine it to your own documentset.
Kind regards,
R Schouten

Open images from Windows store application

I have created a windows store application and I want the user to open Documents, Excel files and picture from the app. I want the files to open in their default application. i.e. Docs in word and pictures in windows picture viewer.
I have used the following code:
FileOpenPicker openPicker = new FileOpenPicker();
openPicker.FileTypeFilter.Add(".Doc");
openPicker.FileTypeFilter.Add(".Docx");
openPicker.FileTypeFilter.Add(".png");
openPicker.FileTypeFilter.Add(".jpg");
StorageFile file = await openPicker.PickSingleFileAsync();
if (file!=null)
{
await Windows.System.Launcher.LaunchFileAsync(file);
}
When I run this and browse to a word document the file opens up fine using word, great.
But if I browse to an image file, it doesn't do anything. I don't get any errors.
Any ideas what I need to do?
Thanks
There is no error and, simply, nothing happens? That's strange.
Here's my go-to syntax, but it's basically yours:
Let's consider what should happen. When you "launch" a docx you are basically asking the default viewer to open for that file, in that case Word. With an image you are asking the image viewer to launch. Should it work? Yes.
Launching a docx when Word is not installed should not result in the behavior your are seeing. No. You should get prompted to find a viewer in the Store. Same with an image. Even without a viewer you should get something.
Not to be a dork here, but have you rebooted? It really sounds more like something strange has happened. You might also try appending "file:///" to the front of the URL to perhaps invoke the file viewer more explicitly. None of that should be necessary however.
Best of luck
One other thing you can do is to force app picker if default program could not be launched like following:
if (file != null)
{
var options = new Windows.System.LauncherOptions();
options.DisplayApplicationPicker = true;
bool success = await Windows.System.Launcher.LaunchFileAsync(file, options);
}

Capture and save a photo in XAML/C# for a Windows store application

I'm trying to take and save a photo using a windows surface device.
I'm using the code below to take a photo and this work but I'd like to automatically create a directory on the device's local drive and save this photo there without any dialog prompts.
So the code I use to capture to photo is as follows:
CameraCaptureUI camera = new CameraCaptureUI();
StorageFile file = await camera.CaptureFileAsync(CameraCaptureUIMode.Photo);
if (file!=null)
{
using (IRandomAccessStream ras=await file.OpenAsync(FileAccessMode.Read))
{
BitmapImage source = new BitmapImage();
source.SetSource(ras);
imageBuildingPhoto.Source = source; // this is just an image control.
}
}
So after this I'd like to automatically save the photo to a new directory. e.g.
My Pictures\NewDirectory\Photo1.jpg
Anybody got any idea how I can do this?
This is a windows store application written using C#4.5 and XAML.
Thanks in advance
Use the CopyAsync method on the StorageFile object you get back (file). You can specify a directory and file name. If you need to create your own directory structure, you will need to enable access to the appropriate library in the Package Manifest then create it in code. You will then use the StorageFolder class and its CreateFolderAsync method to create folders.
http://aka.ms/30Days has some great resources for learning about scenarios like this. Might be worth checking out.
Your code will need to look to see if that folder exists and create it if it does not. Your app will need to declare the capability to access the user's Photos library in the app manifest, too.
To take a picture, your code is correct. I have a walkthrough in case you want to verify it against some other code: http://blog.jerrynixon.com/2012/10/walkthrough-capturing-photos-in-your.html
To interact with the file system, this can be tricky, but I have a longer write up on that if you want to reference it: http://blog.jerrynixon.com/2012/06/windows-8-how-to-read-files-in-winrt.html
The answer to your question is, yes you can. I have done it in my own apps. Now, it's just a matter of you implementing it in yours. You will find it to be pretty easy.

Sharing StorageItems from a byte[] array

I want to implement the Share source contract in my WinRT C# Metro app (Windows Release Preview). My app is storing arbitrary files. Not in the filesystem, but instead I get the data over a WCF service as byte[]. Now I want to share such "files" in my app.
The only possibility I've seen with a standard data format is using the SetStorageItems() method on the DataPackage. Thus I'm facing the challenge to convert the data from my byte array to a StorageFile, which can be shared. I found the StorageFile.CreateStreamedFileAsync() method and wanted to use it in this way:
// filename: string
// fileContent: byte[]
// ... setting DataPackage title and description ...
DataRequestDeferral deferral = args.Request.GetDeferral();
var file = await Windows.Storage.StorageFile.CreateStreamedFileAsync(filename,
async stream => await stream.WriteAsync(fileContent.AsBuffer()), null);
args.Request.Data.SetStorageItems(new List<IStorageItem> { file });
deferral.Complete();
It compiles fine, but it doesn't work as expected. I've tried the sharing with the standard Mail app. The Mail share view opens and I can create a new mail. The file is shown without thumbnail (as expected), but the e-mail can't be sent. It's showing the sending progress for several minutes and then an error occurs: "Couldn't share {filename} with Mail.". The share charm shows "Something went wrong" and "[...] Mail can't share right now. Try again later.".
It works perfectly when I load the StorageFile from the file system: the mail opens and is sent within seconds, no problems here. So either I'm using CreateStreamedFileAsync() wrong or there's a bug in this method, what do you think?
In the callback passed into CreateStreamedFileAsync, you need to actually dispose of the object - that signals to the OS that you are done.
Wrote a complete example here
The Mail app is not a target for sharing files. From http://blogs.msdn.com/b/b8/archive/2012/06/14/building-the-mail-app.aspx: "Mail supports sharing text, links, and pictures."
Remember that there are 2 parts of the Share contract: Share sources and Share targets. As you know, there are many different data formats that can be shared between them, like text, pictures, URIs, and files. The full list of the different data formats that are supported is at http://msdn.microsoft.com/en-us/library/windows/apps/hh771179.aspx.
I recommend that you use the Share Target Sample app to test that your file is being shared properly - share to this and it will display everything that is being shared from your app as a source (and it does accept files for sharing). You can download it from http://code.msdn.microsoft.com/windowsapps/Sharing-Content-Target-App-e2689782. You can also use the Share Source Sample app as an example and leverage code from this app; you can download it from http://code.msdn.microsoft.com/windowsapps/Sharing-Content-Source-App-d9bffd84.
Hope that helps!
Ok, perhaps the preview version of the Mail app doesn't handle the sharing target contract correctly. Using the SDK sample app "Sharing Content Target App" from http://code.msdn.microsoft.com/windowsapps/Sharing-Content-Target-App-e2689782, sharing a StorageItem created in memory with the StorageFile.CreateStreamedFileAsync() method posted above works fine.
Thus, that's the way you should go when you want to share in-memory byte[] arrays. For testing, make sure that the share target app doesn't run in Visual Studio when you want to share data from another app with it. Then the sharing sidebar mysteriously will disappear automatically...