How do I send an email from a WinRT/Windows Store application?

前端 未结 5 829
迷失自我
迷失自我 2020-12-05 20:05

I am developing a Windows Store Application (Windows 8).

I have a need to send emails based on data and address stored in the application data and without the need

5条回答
  •  青春惊慌失措
    2020-12-05 20:45

    If you are developping a Universal WinRT Windows Phone application, you could use the "Windows.ApplicationModel.Email.EmailMessage" namespace as the "Microsoft.Phone.Tasks.EmailComposeTask" namespace doesn't work on WinRT application.

    Then, uses this code to create and launch a new email.

    // Create your new email message.
    var em = new EmailMessage() ;
    
    // Add as much EmailRecipient in it as you need using the following method.
    em.To.Add(new EmailRecipient("yourname@yourdomain.com"));
    em.Subject = "Your Subject...";
    em.Body = "Your email body...";
    // You can add an attachment that way.
    //em.Attachments.Add(new EmailAttachment(...);
    
    // Show the email composer.
    await EmailManager.ShowComposeNewEmailAsync(em);
    

    I hope it will solve your (or other developers) problem.

    Regards.

提交回复
热议问题