I wanted to share some data as mail from my UWP application, but I am unable to change the title (subject of the email), as I am able set title from code but not showing in outlook subject, outlook is using its default subject line as "Text from $SystemsUserName".
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
DataTransferManager dataTransferManager = DataTransferManager.GetForCurrentView();
dataTransferManager.DataRequested += DataTransferManager_DataRequested;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
DataTransferManager.ShowShareUI();
}
void DataTransferManager_DataRequested(DataTransferManager sender, DataRequestedEventArgs args)
{
DataRequest request = args.Request;
request.Data.Properties.Title = "My Custom Subject"; // This is showing as "Text from $SystemsUserName" in the Outlook mail.
request.Data.SetText("This is body of email");
}
}
in xaml part of this page only one button is there which calls "Button_Click" this code shows outlook email window but does not show subject in the mail .
I read the documents on DataRequest
but did not find anything regarding this issue. and also, there is no question regarding this anywhere.
Its Problem with Microsoft Outlook as it overwrites the Subject, and with Microsoft Mail it works fine. The code is right, the bug is in Microsoft Outlook.