Sending email to multiple recipients from UWP stor

2019-07-11 12:56发布

I have a simple goal, to open up an email (in Outlook 2016) with the To field configured for multiple recipients from a Windows 10 UWP app.

I tried 3 approaches

1) The recommended way, as demod in the UWP samples, using the EmailMessage

var emailMessage = new Windows.ApplicationModel.Email.EmailMessage();
            emailMessage.Body = "";

            foreach (Person p in SelectedPeople)
            {
                if (string.IsNullOrEmpty(p.Email) == false)
                {
                    var emailRecipient = new Windows.ApplicationModel.Email.EmailRecipient(p.Email);
                    emailMessage.To.Add(emailRecipient);
                }
            }

            await Windows.ApplicationModel.Email.EmailManager.ShowComposeNewEmailAsync(emailMessage);

This results in an email window with the recipients seperate by commas which then do not resolve. Setting the option to allow comma seperators seemed like an answer, but it tuens out that doesn't work unless there is a space to seperate too?

2) Build a mailto:user1@work.com;user2@work.com URI and launch it.

var uri = new Uri("mailto:user1@work.com;user2@work.com");
var success = await Windows.System.Launcher.LaunchUriAsync(uri);

However, attempting to create URI with multiple recipeitns throws an exception that the URI hostname is invalid

3) Same as above but using the scheme mailto:?To=user1@work.com;user2@work.com

This is parsed correctly as a URI but on launch Outlook shows an empty recipient list. By way of testing, using CC= does show the recipients in the CC field

So, now I am stuck wondering how I can send an email to multiple recipients for a store app?

1条回答
狗以群分
2楼-- · 2019-07-11 13:24

Late to the party, but someone linked this from another question..

Have you tied mailto:user1@work.com%3buser2@work.com

seems to work for me

查看更多
登录 后发表回答