locked
How to send email from outlook from windows store app ? RRS feed

  • Question

  • Hi, 

    I want to send email from my app is it possible to use outlook to send email from windows 8 app??? 

    any suggestion?? 


    Rohit


    • Edited by Rohit2303 Monday, October 21, 2013 7:46 PM
    Monday, October 21, 2013 7:45 PM

Answers

  • For most cases your app should use the share contract to share data via the user's choice of targets. Unless there is a compelling reason to limit the user you should let the user choose.

    If you need to send data to a specific target (for example, feedback on your app) then you can talk directly to your own web service rather than sending the user on a separate jump through email. That way the user can't accidentally redirect the feedback elsewhere.

    If for some reason you specifically need email then you can launch the user's default mail app with a mailto: link or you can talk to specific email servers (Facebook, Exchange, Outlook.com, etc.) via their web services.

    There is no IPC permitted for your app to talk directly to Outlook and there is no in-box mail API.

    --Rob

    Monday, October 21, 2013 8:09 PM
    Moderator
  • No, you can't add an attachment with "mailto".

    In theory you can, but I'm not aware of any apps which will listen for it.

    --Rob

    • Marked as answer by Rohit2303 Wednesday, October 23, 2013 6:42 AM
    Tuesday, October 22, 2013 11:18 PM
    Moderator
  • No you cannot. Haven't tried with attachment. But since you are opening the default email client let the user choose whatever he likes.

    Unless you want to send him a log or something. In that case the only solution that I can think of right now is to create a webservice , send your email as argument in the webservice method , your attachment as a  byte array into your webserver and then from there send him automatically the email.

    I have done this part which sends a request to my webserver , the webservice awakes and then sends to the email that I have passed as an argument in the webservice method the email. 

    But if the attachment is not important then use the code I gave you otherwise you will have to think for a more complex solution like the webservice.

    Hope that help you and gave you a different approach .

    Don't forget to mark me as answered if I answered your question.

    thank you

    • Marked as answer by Rohit2303 Wednesday, October 23, 2013 6:42 AM
    Wednesday, October 23, 2013 5:46 AM

All replies

  • For most cases your app should use the share contract to share data via the user's choice of targets. Unless there is a compelling reason to limit the user you should let the user choose.

    If you need to send data to a specific target (for example, feedback on your app) then you can talk directly to your own web service rather than sending the user on a separate jump through email. That way the user can't accidentally redirect the feedback elsewhere.

    If for some reason you specifically need email then you can launch the user's default mail app with a mailto: link or you can talk to specific email servers (Facebook, Exchange, Outlook.com, etc.) via their web services.

    There is no IPC permitted for your app to talk directly to Outlook and there is no in-box mail API.

    --Rob

    Monday, October 21, 2013 8:09 PM
    Moderator
  • Actually In my case this is a client requirement.. that he wants to send emails from the app and he wants to use outlook to do this.. can't I use the mail app already present in win 8?? e.g. open the mail app from my app with an attachment and on the mail app user will select the recipient and send the mail.

     

    Rohit

    Tuesday, October 22, 2013 7:05 AM
  • Yes, you can do all of that - via the Sharing contract, or doing what Rob said. 

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Tuesday, October 22, 2013 11:54 AM
    Moderator
  • Hi ,

    I don't know if it would help you something like this

      string subject = WebUtility.UrlEncode("mysubject");
               string  body = WebUtility.UrlEncode("mybody");


                string link = string.Format("mailto:{0}?subject={1}&body={2}","", subject, body);
                Launcher.LaunchUriAsync(new Uri(link, UriKind.Absolute));

     The mysubject and the my body there just strings but you will have to encode them first before use the launcher.

    The above will open the email client but it will be outside of your app.

    thank you

    • Marked as answer by Rohit2303 Wednesday, October 23, 2013 6:42 AM
    • Unmarked as answer by Rohit2303 Wednesday, October 23, 2013 6:42 AM
    Tuesday, October 22, 2013 1:28 PM
  • Thanks I shall use the above code.. can I also attach a file with the email?

    Rohit

    Tuesday, October 22, 2013 3:19 PM
  • No, you can't add an attachment with "mailto".

    In theory you can, but I'm not aware of any apps which will listen for it.

    --Rob

    • Marked as answer by Rohit2303 Wednesday, October 23, 2013 6:42 AM
    Tuesday, October 22, 2013 11:18 PM
    Moderator
  • No you cannot. Haven't tried with attachment. But since you are opening the default email client let the user choose whatever he likes.

    Unless you want to send him a log or something. In that case the only solution that I can think of right now is to create a webservice , send your email as argument in the webservice method , your attachment as a  byte array into your webserver and then from there send him automatically the email.

    I have done this part which sends a request to my webserver , the webservice awakes and then sends to the email that I have passed as an argument in the webservice method the email. 

    But if the attachment is not important then use the code I gave you otherwise you will have to think for a more complex solution like the webservice.

    Hope that help you and gave you a different approach .

    Don't forget to mark me as answered if I answered your question.

    thank you

    • Marked as answer by Rohit2303 Wednesday, October 23, 2013 6:42 AM
    Wednesday, October 23, 2013 5:46 AM
  • Thanks a lot man... now I'll write a web service and use that to send emails.

    Rohit

    Wednesday, October 23, 2013 6:41 AM
  • Wednesday, October 23, 2013 6:49 AM
  • Thanks for this link but I am dropping my plan to use launcher to send email instead of doing that I'll use a webservice now. Thanks anyways for the suggestion.


    Rohit

    Wednesday, October 23, 2013 7:37 AM