Email with attachments
I am trying to add attachments to an email, but its always null
In my mailDto i have IFormFile List to store the attachments, but from all my research in the frontend they use an IBrowserFile to show selected files. How can i send my IBrowserFile to my IFormFileList. I will attach screenshots for reference
If you need any more information, please ask! Thanks!
23 Replies
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Would SendGrid be a better option?
SMTP was just the first i stumbled upon, seemed to have lots of documentation and guides
I am using Mailkit btw, just using an instance of SMTPClient for configuration of mail settings
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Indeed it is using MailKit.Net.Smtp;
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
But also someone suggested SendGrid when i first started this email thingf
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
My only problem is frontend, in swagger everything works fine, but i need to figure out how i can take the uploaded files, and send them into my MailDTO list of attachments..
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
In case you did not read the docs:
https://docs.microsoft.com/en-us/aspnet/core/mvc/models/file-uploads?view=aspnetcore-6.0
Client Code:
ServerCode:
The field's name in the body when doing the POST, needs to match the binded field in the Controler's Action
https://media.discordapp.net/attachments/569261465463160900/1001188081069735936/unknown.png
Upload files in ASP.NET Core
How to use model binding and streaming to upload files in ASP.NET Core MVC.
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
So you suggest uploading every file by itself, adding them 1 by one to the email?
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
This is true
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
So i would create like an UploadResult model?
to hold the data
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Aight, its a bit more complicated than i anticipated with this email, i'll dig into it
So actually my first step is to upload the attachment, and then worrying about sending an email with it after
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
My end goal is to be able to send automated emails based on some input, but just starting with manually sending an e-mail
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Yep, i thought so
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View