まず、Windows 8 Metroアプリケーションのコンテンツを別のアプリ(Mailtoアプリなど)に共有しているので、次のようにします。
現在、共有コントラクトを使用してmailtoアプリにファイルを共有し、アプリケーションからファイルを共有しています。
私は次のことを知りたかった:-
そのmailtoアプリの添付ファイルとしてファイルを共有しているmailtoアプリの件名を設定できますか?その場合、どうすればよいですか?
そうでない場合は、回避策を教えてください。
まず、Windows 8 Metroアプリケーションのコンテンツを別のアプリ(Mailtoアプリなど)に共有しているので、次のようにします。
現在、共有コントラクトを使用してmailtoアプリにファイルを共有し、アプリケーションからファイルを共有しています。
私は次のことを知りたかった:-
そのmailtoアプリの添付ファイルとしてファイルを共有しているmailtoアプリの件名を設定できますか?その場合、どうすればよいですか?
そうでない場合は、回避策を教えてください。
今のところ、それは不可能です。
Windows 8 では最近、プロトコル アクティベーションと呼ばれる新しい API が導入されました。プロトコル アクティベーションを使用すると、アプリケーションから他の Windows 8 アプリを起動してデータを渡すことができます。Microsoft はマップ アプリに取り組んでおり、ここに示すようにマップ アプリに情報を渡すことができるようになりました (マップ アプリケーションの 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セント
いいえ、現時点ではできません。
質問を正しく理解していないかもしれませんが、チャーム バーの [共有] ボタンをクリックする機能だけが必要な場合は、[メール] アプリを選択して、 「メール」アプリの共有フライアウトが表示されたら、次のアプローチに従うことができます。
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();
}
}