Attachment not attached in Outlook mail system in C# UWP

Jay 100 Reputation points
2024-10-02T13:02:10.9666667+00:00

Hi, I am trying to attach a file in the Outlook mail system using C# UWP, but it's not working. It works fine in the old Mail app. Could you please help?

Code:

EmailMessage emailMessage = new EmailMessage(); 
StorageFile attachmentFile = await storageFolder.GetFileAsync("TXT_Files\\Purchase Status.txt");
 if (attachmentFile != null)
 {
     var stream = Windows.Storage.Streams.RandomAccessStreamReference.CreateFromFile(attachmentFile);
     var attachment = new Windows.ApplicationModel.Email.EmailAttachment(attachmentFile.Name, stream);
     emailMessage.Attachments.Add(attachment);
 }
await EmailManager.ShowComposeNewEmailAsync(emailMessage);
Universal Windows Platform (UWP)
{count} votes

Accepted answer
  1. Viorel 117K Reputation points
    2024-10-02T16:47:38.3966667+00:00

    It seems that the attachments “... will appear only in the Mail app. If users have any other mail program configured as their default mail program, the compose window will appear without the attachment. This is a known issue”:

    To work around the momentary known issue, maybe you can insert the Purchase Status to the body of email.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.