C
C#2y ago
Obel

Sending email SMTP[Answered]

I am trying to send an email using SMTP. The backend works, and i can send emails via Swagger. But i just cannot make it work from the Blazor FrontEnd I get the MimeKit No address found exception as seen in the snippet. I have a service on the client that refers to the controller and service on server side. Gonna attach snippets of relevant classes Thanks for the help in advance! 🙂
12 Replies
Anchy
Anchy2y ago
Set a breakpoint and see what the value of request.To is
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Obel
Obel2y ago
Yes, it just seems that the ''To'' email is not recognized by MimeKit, and im not sure why
Anchy
Anchy2y ago
That specific error shows up when the startIndex and endIndex is equal in the parser so my guess is your To is an empty string or something if I read the parser correctly
Obel
Obel2y ago
Yes, the issue is definitely, that the frontend input is not processed to the backend. I've been trying a few things to fix it, but i just cant figure it out. Maybe i'll look into SendGrid
Anchy
Anchy2y ago
Try use [FromBody] instead of [FromForm] because I see you are posting using json and I think the attributes handle the information differently?
Obel
Obel2y ago
But as you can see, it does take the input
Anchy
Anchy2y ago
I'm not an asp.net user so I'm kind of stabbing in the dark
Obel
Obel2y ago
Oh true, [FromForm] was used for swagger testing, lets try that
Anchy
Anchy2y ago
I was reading this stack overflow post that stated
The FromForm attribute is for incoming data from a submitted form sent by the content type application/x-www-form-urlencoded while the FromBody will parse the model the default way, which in most cases are sent by the content type application/json, from the request body.
The FromForm attribute is for incoming data from a submitted form sent by the content type application/x-www-form-urlencoded while the FromBody will parse the model the default way, which in most cases are sent by the content type application/json, from the request body.
https://stackoverflow.com/questions/50453578/asp-net-core-fromform-and-frombody-same-action
Obel
Obel2y ago
Thanks, that was literally the problem
Anchy
Anchy2y ago
nice
Want results from more Discord servers?
Add your server
More Posts