I need to send an email with a log file from my windows phone 8.1 app. I found this way :
var mailto = new Uri("mailto:[email protected]&subject=The subject of an email&body=Hello from a Windows 8 Metro app.");
await Windows.System.Launcher.LaunchUriAsync(mailto);
Is there a special parameter to specify the attach file or another completly different way ?
You should be able to use EmailMessage class for this. A sample code can look like this:
private async void SendBtn_Click(object sender, RoutedEventArgs e)
{
EmailMessage email = new EmailMessage { Subject = "Sending test file" };
email.To.Add(new EmailRecipient("[email protected]"));
// 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
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With