-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
Hi! I have the following code. When i add the attachment the mail can not be created. Windows 10 UWP. With EASendMailRT it works.
using (SmtpClient client = new SmtpClient("smtp.host.com", 465, true, "my@email.com", "123"))
{
var emailMessage = new EmailMessage();
emailMessage.To.Add(new EmailRecipient("to@email.com"));
emailMessage.Subject = "A new email has arrived";
emailMessage.Body = "Export File";
Windows.Storage.StorageFolder storageFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
Windows.Storage.StorageFile attachmentFile = await storageFolder.GetFileAsync("export.txt");
if (attachmentFile != null)
{
var stream = RandomAccessStreamReference.CreateFromFile(attachmentFile);
emailMessage.Attachments.Add(new EmailAttachment(attachmentFile.Name, stream));
SmtpResult ex = await client.SendMailAsync(emailMessage);
var messageDialog = new MessageDialog("Email Code: " + ex.ToString());
await messageDialog.ShowAsync();
}
}
Metadata
Metadata
Assignees
Labels
No labels