I have faced a problem, that Sharing in windows 8 is very buggy. Because i downloaded a sample from MSDN "Sharing content source app sample" and it worked fine few times (lets say 3). On a 4 time when i ran the sample it shows:
Can't share at the moment ( internet is up and mail accounts are connected )
On 5 time it generated the mail content but couldn't send, and so on.
So in my own application, i have seen the same picture. Can anybody tell what is the problem?
Specially for this, i have created a small app:
public sealed partial class MainPage : Page
{
DataTransferManager dtm;
public MainPage()
{
this.InitializeComponent();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
dtm = DataTransferManager.GetForCurrentView();
dtm.DataRequested += OnDataRequested;
}
protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
{
dtm.DataRequested -= OnDataRequested;
base.OnNavigatingFrom(e);
}
private async void OnDataRequested(DataTransferManager sender, DataRequestedEventArgs e)
{
DataRequestDeferral deferral = e.Request.GetDeferral();
var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(@"shareappemail.html");
var stream = await file.OpenReadAsync();
var rdr = new StreamReader(stream.AsStream());
var contents = await rdr.ReadToEndAsync();
DataPackage requestData = e.Request.Data;
requestData.Properties.Title = "MyAppTitle";
requestData.Properties.Description = "ShareWithSomebody"; // The description is optional.
requestData.SetHtmlFormat(HtmlFormatHelper.CreateHtmlFormat(contents));
deferral.Complete();
}
}
shareappemail.html - is just some html template of an email.
And this code doesn't work... Can somebody tell what is wrong? ( Even Microsoft Photo app isn't sharing... )