Is it possible to set a subject to the mail app in Windows 8 metro application, if I am using share contract and sharing files?

血红的双手。 提交于 2019-12-05 07:23:36

As of now, it's not possible.

Windows 8 recently introduced a new API called protocol activation. With Protocol activation, you can launch other windows 8 apps from your application and pass in data. Microsoft worked on Maps app and you can now pass information to the Map app as shown here (URI Scheme for maps application) http://msdn.microsoft.com/en-us/library/windows/apps/jj635237.aspx

See a code walkthrough at http://blog.jerrynixon.com/2012/10/walkthrough-using-windows-8-custom.html

Now, i am sure very soon, you will see some custom parameters for Mail app that you can pass from your app using protocol activation.

Just my 2 cents

No, it isn't possible to do this at the moment.

I may not be understanding the question correctly but if all you want to do is have the ability to click the "Share" button on the Charms Bar, then select the "Mail" app and have the ability to populate the subject line shown when the "Mail" app's share fly-out is displayed then you can follow this approach:

private DataTransferManager dataTransferManager; //class member

// put the following code block wherever you need it:

// Register as a share source
if (this.dataTransferManager == null)
{
    this.dataTransferManager = DataTransferManager.GetForCurrentView();
    this.dataTransferManager.DataRequested -= this.OnDataRequested;

    try
    {
        this.dataTransferManager.DataRequested += new TypedEventHandler<DataTransferManager, DataRequestedEventArgs>(this.OnDataRequested);
    }
    catch 
    { 
    };
}

private void OnDataRequested(DataTransferManager sender, DataRequestedEventArgs e)
{
    DataRequest request = e.Request;
    DataRequestDeferral deferal = request.GetDeferral();

    try
    {
        // this property will set your subject line
        // it will also be shown on the Share fly-out (right below the main 
        // heading that says 'Share'
        request.Data.Properties.Title = GetCustomMailSubjectLine();

        if (string.IsNullOrEmpty(request.Data.Properties.Title))
        {
            request.FailWithDisplayText("An operation failed. Please try again.");
        }
        else
        {
            // this will also be shown on the Share fly-out, right below the 'Title'
            // property set above
            request.Data.Properties.Description = GetMyAppsSharingDesciption();

            // use request.Data.SetDataProvider() if your data needs to be asynchronously retrieved
            // otherwise directly use request.Data.SetData() (or one of the other 
            //methods depending on what you need)

            request.Data.SetDataProvider(StandardDataFormats.Html, RetrieveSharedData);
        }
    }
    finally
    {
        deferal.Complete();
    }
}

private async void RetrieveSharedData(DataProviderRequest request)
{
    DataProviderDeferral deferal = request.GetDeferral();

    try
    {
        // this will set your email's body
        request.SetData(await GetCustomMailBodyAsync());
    }
    finally
    {
        deferal.Complete();
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!