Last post Apr 23, 2020 10:29 PM by sapper6fd
Apr 23, 2020 01:59 AM|sapper6fd|LINK
I'm learning to code by developing a project that uses Angular and .NET core for an API. I'm starting into a new area of this project that I'm hoping to get a little advice on as it a new area to me, and thats sending emails from the project.
There are 2 factions to the project:
A: Sending platform emails (IE: Registration emails, password resets, stuff the user requests from the Angular project)
B: Automatic reporting emails that contain data submitted to the project via a mobile app through the API.
For the platform emails, I understand this needs to be done in the Angular project itself. However, when someone submits data via the API with the use of a phone based app, an email should be sent to a designated person containing the data that was submitted.
This last part is where I'm running into troubles figuring out what needs to be done.
I'm going to incorporate SendGrid into the project to handle all of the emails. However, what is the best practice to send the emails to the designated person when info is passed via a mobile app through the API? I'm going to assume this would be built in
the API itself as it wouldn't be a user triggered event in the Angular project. In fact, the Angular project wouldn't even be aware that the data had been submitted.
Any advice on how I would tackle this? Would I build a trigger within the API that is tripped when the data is submitted that tells Sendgrid to send the email with the data? Would this be built within the .NET API? And how does one build an email template
using just C#?
Thanks in advance for any input provided!
Apr 23, 2020 10:03 AM|mgebhard|LINK
I'm going to incorporate SendGrid into the project to handle all of the emails. However, what is the best practice to send the emails to the designated person when info is passed via a mobile app through the API?
The user's identity must be passed to the API. Your application should allow users to register and login.
Apr 23, 2020 05:07 PM|bruce (sqlwork.com)|LINK
your angular project should have two projects
1) the client angular project that builds the angular program to download to the client
2) the server webapi project that the angular code calls. this project is callable from mobile just as easily as from an angular application. you use security access to prevent the angular code from calling the mobile code and vice-versa.
Apr 23, 2020 10:29 PM|sapper6fd|LINK
Hey there, thanks for the response.
what you stated above is what I have.
1) Client Angular Project - how users interact with the project through their web browsers
2) The WebAPI which the Angular code and a mobile application calls to provide and receive user generated content.
There is security in place to prevent unauthorized users from accessing the WebAPI and registered areas of the Angular project (I'm currently using JWT tokens for this). The part I'm looking to create now though is the emailing functionality. I don't think
I did very well at explaining it above.
If someone who is logged in via a mobile app submits data (IE text and an image), that is handled by the WebAPI, what would be the best way for an email to be generated once that data is submitted via the WebAPI. Would this be a third project within my
application? Is there a way to generate email templates through C# without using a Razor Pages project that can be used and then submitted to Sendgrid to be emailed out with the appropriate content retrieved from the WebAPI / Database?