tuf*_*koi 3 c# windows-runtime windows-phone-8.1
我需要从我的Windows Phone 8.1应用程序发送一封包含日志文件的电子邮件.我发现了这种方式:
var mailto = new Uri("mailto:?to=recipient@example.com&subject=The subject of an email&body=Hello from a Windows 8 Metro app.");
await Windows.System.Launcher.LaunchUriAsync(mailto);
Run Code Online (Sandbox Code Playgroud)
是否有一个特殊的参数来指定附件文件或另一种完全不同的方式?
您应该可以使用EmailMessage类.示例代码可能如下所示:
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
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1032 次 |
| 最近记录: |