TL;TR
Don’t try to create an UWP app that tries to access emails. This is not allowed for „common developers“.
Idea for a new app: Show preview of emails on a live tile
Today I got a suggestion from a user of my app Live Tile Calendar 10: Similar to seeing a list of future appointments on the live tile, it would be nice to see a preview of new email messages on a live tile!
A nice idea and many apps (WhatsApp, Facebook, Skype, Slack, …) do this: Show a preview of new messages.
Yes, I know – when a mailbox is pinned to the start screen it shows the last (but only one!) email message too. I would like to have some options here, like showing 4 messages on the front and 4 more messages on the back side of the live tile, show important emails only, show emails from a specific sender only, …
So I started searching and found the EmailManager class, which provides a RequestStoreAsync method.
var emailStore = await EmailManager.RequestStoreAsync(EmailStoreAccessType.AllMailboxesLimitedReadWrite);
This looks quite similar to the AppointmentManager which also provides a method RequestStoreAsync to get access to the appointments store…and show them on a live tile, like Live Tile Calendar 10 does.
var appointmentStore = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AllCalendarsReadOnly);
I quickly created a new, blank UWP app in VS2015 and wrote some code. Idea of the prototype: Query new email messages and show them in a listbox.
var emailStore = await EmailManager.RequestStoreAsync(EmailStoreAccessType.AllMailboxesLimitedReadWrite); var mailboxes = await emailStore.FindMailboxesAsync(); if (mailboxes.Any()) { var inbox = await mailboxes.First().GetSpecialFolderAsync(EmailSpecialFolderKind.Inbox); var messageReader = inbox.GetMessageReader(new EmailQueryOptions {Kind = EmailQueryKind.Unread}); var batchResult = await messageReader.ReadBatchAsync(); foreach (var emailMessage in batchResult.Messages) { ... } }
When starting the app, I got a nice error message when EmailManager.RequestStoreAsync was called.
This message is not uncommon to windows app developers. Is usually means you forgot to add some permission in the app manifest. So I checked there for a permission to access emails. Btw. you can see the „Appointments“ permission here, which is required for an app to query appointments. Unfortunately there is no entry for something like „email“. 🙁
After some search on StackOverflow and the MSDN developer forums I finally found this thread: https://social.msdn.microsoft.com/Forums/en-US/343d356b-66ad-47b7-83ba-4673ba0ca0e7/uwpacces-denied-for-emailmanagerrequeststoreasync?forum=wpdevelop
So this means: No access to emails for „normal developers“.
The site for app capability declaration says:
In contrast, restricted capabilities do not require a special company account for the Store, they are not available for developers to use. Restricted capabilities are available only to apps that are developed by Microsoft and its partners.
But Why?
Why can’t I create an app that fulfills a request from a user of one of my other apps?
Why can’t there be an „email capability“ like there is one for appointments?
Why does MS make it impossible to create a simple app that shows emails on a live tile?
Very sad for developers. The same limitation exists to my knowledge at the people hub API for app integration, that would be very cool if it works…
I have a question regards the RS1 SDK, is the API bug still here, that you cannot create the UWP Week View app?
Hi Jan,
I tested this with the most recent „release preview ring“ build and it seems that MS has finally fixed the problem (after 1 year of waiting for it).
This means, porting Week View to an UWP finally makes sense. Another no technical issue of course is: Currently I am working on other projects, so I do not have much time at the moment.
Sales of windows phones and apps rapidly dropped the last months…so maybe creating a Xamarin based app that runs on Android an IOs too makes more sense…I will have to think about this.
greetings,
Hannes
Hi Hannes,
that sounds great. I agree that the marketshare are very bad at Windows Phone, but I looking forward to the influence on app development by Windows 10 PC and Console. I have only a WP8.1 device but Week View would be really nice on PC and I am sure that not a few there are who need a better calendar.
best regards,
Jan