C# 使用附加文件WinRT发送电子邮件

C# 使用附加文件WinRT发送电子邮件,c#,windows-runtime,windows-phone-8.1,C#,Windows Runtime,Windows Phone 8.1,我需要从我的windows phone 8.1应用程序发送一封包含日志文件的电子邮件。我发现: 是否有一个特殊参数来指定附加文件或其他完全不同的方式?您应该能够使用它。示例代码可以如下所示: private async void SendBtn_Click(object sender, RoutedEventArgs e) { EmailMessage email = new EmailMessage { Subject = "Sending test file" }; emai

我需要从我的windows phone 8.1应用程序发送一封包含日志文件的电子邮件。我发现:

是否有一个特殊参数来指定附加文件或其他完全不同的方式?

您应该能够使用它。示例代码可以如下所示:

private async void SendBtn_Click(object sender, RoutedEventArgs e)
{
    EmailMessage email = new EmailMessage { Subject = "Sending test file" };
    email.To.Add(new EmailRecipient("myMailbox@mail.com"));

    // Create a sample file to send
    StorageFile file = await ApplicationData.Current.LocalFolder.CreateFileAsync("testFile.txt", Windows.Storage.CreationCollisionOption.ReplaceExisting);
    await FileIO.WriteTextAsync(file, "Something inside a file");

    email.Attachments.Add(new EmailAttachment(file.Name, file)); // add attachment
    await EmailManager.ShowComposeNewEmailAsync(email); // send email
}

我使用DataTransferManager准备内容,然后让用户选择电子邮件应用程序,我成功地设置了邮件标题:
request.Data.Properties.title=loger.GetFileName()但不是目的地。有什么帮助吗?非常感谢!我认为不可能使用这些类。。。我阅读了Windows.ApplicationModel.Email名称空间,因为它只是说“本主题中描述的功能不适用于所有Windows和Windows Phone应用程序。对于您的代码…等”,接受的答案不会将电子邮件附加到任何win32电子邮件应用程序(如Outlook)。附加到电子邮件仅适用于Windows Mail应用商店应用
private async void SendBtn_Click(object sender, RoutedEventArgs e)
{
    EmailMessage email = new EmailMessage { Subject = "Sending test file" };
    email.To.Add(new EmailRecipient("myMailbox@mail.com"));

    // Create a sample file to send
    StorageFile file = await ApplicationData.Current.LocalFolder.CreateFileAsync("testFile.txt", Windows.Storage.CreationCollisionOption.ReplaceExisting);
    await FileIO.WriteTextAsync(file, "Something inside a file");

    email.Attachments.Add(new EmailAttachment(file.Name, file)); // add attachment
    await EmailManager.ShowComposeNewEmailAsync(email); // send email
}