【问题标题】: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?如果我使用共享合同和共享文件,是否可以在 Windows 8 Metro 应用程序中为邮件应用程序设置主题?
【发布时间】:2012-10-26 06:14:29
【问题描述】:

首先,我将 Windows 8 Metro 应用程序中的内容共享到另一个应用程序(例如 Mailto 应用程序),因此:

现在我正在使用共享合同将文件共享到 mailto 应用程序并从我的应用程序共享文件,

我想知道:-

  1. 我可以将主题设置为我共享文件的 mailto 应用,作为该 mailto 应用的附件吗?如果可以,请告诉我该怎么做?

  2. 如果没有,请告诉我解决方法是什么?

【问题讨论】:

    标签: email microsoft-metro windows-runtime winrt-xaml


    【解决方案1】:

    不,目前无法执行此操作。

    【讨论】:

      【解决方案2】:

      到目前为止,这是不可能的。

      Windows 8 最近引入了一种称为协议激活的新 API。通过协议激活,您可以从您的应用程序启动其他 Windows 8 应用程序并传入数据。 Microsoft 致力于 Maps 应用程序,您现在可以将信息传递给 Maps 应用程序,如下所示(地图应用程序的 URI 方案)http://msdn.microsoft.com/en-us/library/windows/apps/jj635237.aspx

      http://blog.jerrynixon.com/2012/10/walkthrough-using-windows-8-custom.html查看代码演练

      现在,我敢肯定,您很快就会看到邮件应用的一些自定义参数,您可以使用协议激活从您的应用传递这些参数。

      只要我的 2 美分

      【讨论】:

        【解决方案3】:

        我可能没有正确理解这个问题,但如果您只想点击超级按钮栏上的“分享”按钮,然后选择“邮件”应用程序并能够填充主题行显示“邮件”应用的共享飞出时显示,然后您可以按照以下方法:

        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();
            }
        }
        

        【讨论】:

          猜你喜欢
          • 2013-02-23
          • 1970-01-01
          • 2023-03-21
          • 1970-01-01
          • 1970-01-01
          • 2019-03-29
          • 2012-09-24
          • 1970-01-01
          相关资源
          最近更新 更多