The following forum(s) have migrated to Microsoft Q&A (Preview): Developing Universal Windows apps!
Visit Microsoft Q&A (Preview) to post new questions.

Learn More

 locked
[UWP]Sharing HTML with embedded images does NOT work anymore ! (Target Mail App) RRS feed

  • Question

  • Hi,
    I added sharing to my app and referred to this example from Microsoft:

    https://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh973055

    This is no more working for a UWP app on windows 10 (Build 1151). It worked on Win 8.1 app very well.

    I can select the mail app but after selecting the mail account - I see a progress panel and nothing more...
    Seems to be a deadlock in mail app!?

    Here is the code from the sample:

      private async void DatatransferManagerDataRequested(DataTransferManager aSender, DataRequestedEventArgs aEventArgs)
            {
                DataRequest request = aEventArgs.Request;
                DataRequestDeferral dataRequestDeferral = request.GetDeferral();
    
    
                request.Data.Properties.Title = "Share Html Example";
                request.Data.Properties.Description =
                    "Demonstrates how to share an HTML fragment with a local image.";
    
                string localImage = "ms-appx:///Assets/Logo.png";
                string htmlExample = "<p>Here is a local image:</br><img src=\"" + localImage + "\"></p>";
                string htmlFormat = HtmlFormatHelper.CreateHtmlFormat(htmlExample);
                request.Data.SetHtmlFormat(htmlFormat);
    
                // Because the HTML contains a local image, we need to add it to the ResourceMap.
                RandomAccessStreamReference streamRef =
                     RandomAccessStreamReference.CreateFromUri(new Uri(localImage));
                request.Data.ResourceMap[localImage] = streamRef;
    
                dataRequestDeferral.Complete();
            }


    • Edited by Krunal Parekh Thursday, April 7, 2016 4:18 AM subject
    Wednesday, April 6, 2016 3:17 PM

Answers

  • VS Studio:

    Microsoft Visual Studio Professional 2015
    Version 14.0.24720.00 Update 1
    Microsoft .NET Framework
    Version 4.6.01038

    Installed Version: Professional

    Visual Studio Tools for Universal Windows Apps   14.0.24720.00

    Windows 10 Enterprise 10.0.10586 Build 10586

    project.json

    "Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0",

    Microsoft .Net Framework 4.6.1 SDK


    Hi duck42,

    >>I still have the problem that the mail app just shows a white panel with loading dots at the top and never comes back.

    This issue is related to the Mail app on Windows 10, if you tried the official Share Target sample, the shared content could be shared correctly.

    If you are just developing the share source app, this issue won't block your dev progress, I also recommend you using the official Feedback app to report the issue for this official app.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by duck42 Friday, April 29, 2016 7:30 AM
    Friday, April 29, 2016 7:06 AM
    Moderator

All replies

  • hi duck42,

    >>           string localImage = "ms-appx:///Assets/Logo.png";

    Is your image name is Logo or StoreLogo by default the name should be StoreLogo in UWP. I tested below in UWP app and it works fine. 

    namespace App1
    {
    	/// <summary>
    	/// An empty page that can be used on its own or navigated to within a Frame.
    	/// </summary>
    	public sealed partial class MainPage : Page
    	{
    		public MainPage()
    		{
    			this.InitializeComponent();
    			RegisterForShare();
    		}
    
    		private void RegisterForShare()
    		{
    			DataTransferManager dataTransferManager = DataTransferManager.GetForCurrentView();
    			dataTransferManager.DataRequested += new TypedEventHandler<DataTransferManager,
    					DataRequestedEventArgs>(this.ShareHtmlHandler);
    		}
    
    		private void ShareHtmlHandler(DataTransferManager sender, DataRequestedEventArgs e)
    		{
    			DataRequest request = e.Request;
    			DataRequestDeferral dataRequestDeferral = request.GetDeferral();
    
    			request.Data.Properties.Title = "Share Html Example";
    			request.Data.Properties.Description =
    					"Demonstrates how to share an HTML fragment with a local image.";
    
    			string localImage = "ms-appx:///Assets/StoreLogo.png";
    			string htmlExample = "<p>Here is a local image: <img src=\"" + localImage + "\">.</p>";
    			string htmlFormat = HtmlFormatHelper.CreateHtmlFormat(htmlExample);
    			request.Data.SetHtmlFormat(htmlFormat);
    
    			// Because the HTML contains a local image, we need to add it to the ResourceMap.
    			RandomAccessStreamReference streamRef =
    					 RandomAccessStreamReference.CreateFromUri(new Uri(localImage));
    			request.Data.ResourceMap[localImage] = streamRef;
    			dataRequestDeferral.Complete();
    		}
    
    		private void Button_Click(object sender, RoutedEventArgs e)
    		{
    			DataTransferManager.ShowShareUI();
    		}
    	}
    }
    

    Result 

    With Regards,

    Krunal Parekh 


    Thanks MSDN Community Support Please remember to Mark as Answer the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    • Proposed as answer by Krunal Parekh Thursday, April 7, 2016 4:20 AM
    Thursday, April 7, 2016 4:18 AM
  • Hi Krunal,

    fine that this example works on your machine - I have tried to use the store logo but this did not help :(

    I verified that the png exists and used exactly your code... mail does not get opened:

    I still have the problem that the mail app just shows a white panel with loading dots at the top and never comes back.

    When I do not put the png in the RessourceMap the mail opens as desired (of course the png is just a place holder):

    // these lines seem to make my mail app hang!
    // RandomAccessStreamReference streamRef =  RandomAccessStreamReference.CreateFromUri(new Uri(localImage));
    // request.Data.ResourceMap[localImage] = streamRef;

    Things i tried - but none of the tipps helped:

    I also took care of the names of the localImage as described here.

    And I used the URI like described here - but still not working :(

    I think there is kind a deadlock problem... the mail with the picture is never opened.

    Any ideas?

    Andi

    Thursday, April 7, 2016 7:40 AM
  • Hi duck42,

    >>I think there is kind a deadlock problem... the mail with the picture is never opened.

    >>Any ideas?

    Perhaps it could be issue with the mail app it self. Did you try other share target other than mail app? For example one note? 

    If the issue is specific to mail app then i would recommend that you submit feedback using feedback tool. 

    Please see: Updates and feedback

    With Regards,

    Krunal Parekh


    Thanks MSDN Community Support Please remember to Mark as Answer the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Saturday, April 9, 2016 6:23 AM
  • I posted this thread as a problem to mail app. But I don't know if anybody cares about it.

    May anybody at Microsoft check this out!?

    I can not believe that sharing HTML with embedded pictures is a uncommon task.

    Our app relies on it because we create graphs as pictures and embedded into HTML for sharing.

    This feature has completly gone.

    I tried to use the Share Source Sample app and used the source code from the sample.

    On two devices I get the same result - mail app with progress dots and never comes back :(

    I also edited Share Target Sample app to get the bitmap from the ResourceMap and hey there I can read the embedded picture.

    So guys put your heads together and try this out.

    Thank you,

    Andi

    Monday, April 11, 2016 2:10 PM
  • Hi,

    Could you give us your environment details. VS studio version, SDK version and windows 10 version? 


    Thanks MSDN Community Support Please remember to Mark as Answer the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Tuesday, April 19, 2016 2:06 AM
  • VS Studio:

    Microsoft Visual Studio Professional 2015
    Version 14.0.24720.00 Update 1
    Microsoft .NET Framework
    Version 4.6.01038

    Installed Version: Professional

    Visual Studio Tools for Universal Windows Apps   14.0.24720.00

    Windows 10 Enterprise 10.0.10586 Build 10586

    project.json

    "Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0",

    Microsoft .Net Framework 4.6.1 SDK

    Tuesday, April 19, 2016 8:31 AM
  • VS Studio:

    Microsoft Visual Studio Professional 2015
    Version 14.0.24720.00 Update 1
    Microsoft .NET Framework
    Version 4.6.01038

    Installed Version: Professional

    Visual Studio Tools for Universal Windows Apps   14.0.24720.00

    Windows 10 Enterprise 10.0.10586 Build 10586

    project.json

    "Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0",

    Microsoft .Net Framework 4.6.1 SDK


    Hi duck42,

    >>I still have the problem that the mail app just shows a white panel with loading dots at the top and never comes back.

    This issue is related to the Mail app on Windows 10, if you tried the official Share Target sample, the shared content could be shared correctly.

    If you are just developing the share source app, this issue won't block your dev progress, I also recommend you using the official Feedback app to report the issue for this official app.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by duck42 Friday, April 29, 2016 7:30 AM
    Friday, April 29, 2016 7:06 AM
    Moderator
  • Hi Franklin,

    please could you also pass this error to the mail app team.

    You may have a direct line to them... ;-)

    Thank you,

    Andi

    Friday, April 29, 2016 7:30 AM