Reputation: 991
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 ?
Upvotes: 3
Views: 1307
Reputation: 29792
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
}
Upvotes: 6