Attachment not attached in Outlook mail system in C# UWP

Jay 160 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);
Developer technologies | Universal Windows Platform (UWP)
Developer technologies | C#
Developer technologies | C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
{count} votes

Answer accepted by question author
  1. Viorel 126.3K 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.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

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