locked
Sending an email from my web app RRS feed

  • Question

  • User-702124402 posted

    Hi, 

    I have created a web app for work that sends data input by the user to a database, that's working perfect. My question how can I get my form to send and email as well as populate the database when the submit button is clicked by the user? Any help would be very much appreciated.

    Thanks

    Monday, July 6, 2020 4:34 PM

All replies

  • User475983607 posted

    The first step is contacting your email provider to get the setting you need to use to send email.  The next step is settling on the library to use for sending email.

    https://docs.microsoft.com/en-us/dotnet/api/system.net.mail.smtpclient?view=netcore-3.1

    https://www.nuget.org/packages/MailKit/

    Monday, July 6, 2020 4:44 PM
  • User-702124402 posted

    Is this the same process that you need to follow if you're using Razor Pages? I'm still pretty new when it comes to ASP.NET Core just don't want to miss anything/mess anything up.

    Monday, July 6, 2020 5:34 PM
  • User475983607 posted

    Is this the same process that you need to follow if you're using Razor Pages? I'm still pretty new when it comes to ASP.NET Core just don't want to miss anything/mess anything up.

    In Razor Pages it is common to create and register a service with the DI framework.  The actual code to send email has little to do with Razor Pages.  You still need to know the server/service domain, port, login credentials, from address, and to address.  This is the information you need to get from you email service.  And you still need to settle on a library to use to create and send the email.

    Monday, July 6, 2020 6:08 PM
  • User-702124402 posted

    Okay thanks! I'm pretty sure I have everything I need from the email service I'm going to give it a try with MailKit I think. Just once more quest can I use microsoft.asp.netcore.identity.ui for my library or is it better to stick with MailKit?

    Monday, July 6, 2020 6:12 PM
  • User475983607 posted

    Okay thanks! I'm pretty sure I have everything I need from the email service I'm going to give it a try with MailKit I think. Just once more quest can I use microsoft.asp.netcore.identity.ui for my library or is it better to stick with MailKit?

    Your confused.  Identity is an account management API.  MailKit is a library to send email which Identity might call.

    Monday, July 6, 2020 6:18 PM
  • User-702124402 posted

    Ohhh okay! I got you now thanks so much!

    Tuesday, July 7, 2020 10:58 AM