In this article, I'm going to tell you how to send multiple emails with multiple attachments (Sending Bulk Mails) in MVC.
Regardless of which platform you are working on like .NET, Python, Java, etc, sending an email is the basic requirement. In a web application, an email may be required to send One Time Passwords (OTPs) for confirmation of user authentication, also for sending notifications, etc. The most valuable service nowadays which comes free of cost is email. To send an email, one should use SMTP (Simple Mail Transfer Protocol ) as a method to transfer mail from one user to another. SMTP is a push-type protocol and is very useful to send the emails whereas POP (post office protocol) or IMAP (internet message access protocol) are used to retrieve those emails at the receiver’s side.
To use SMTP, one should have network credentials for authentication purposes.
Sending multiple emails is the same as sending a single email. The difference is that to send the multiple emails one should add the emails into a list and pass the list such that email function should loop for the number of mails in it
Source Code
First of all, declare the Namespace "using System.Net.Mail."
For basic understanding, I'm giving the source code of three methods which are used to send mail.
Code 1
This method name is BulkEmail and its return type is a string. This method is just used to call the mail methods which are in void type.
- public string BulkEmail()
- {
- BuildEmail();
- return "Success";
- }
Code 2
In this BuildEmail method, one can append the set of recipient emails to a list and by iterating the for loop, one can send email message to each and every receipient using MailMesage object. In MailMessage object, we need to declare the properties like From, To, Subject, Body, Attachments, etc,. In case, there is a need to send the documents like pdf, doc etc, one can attach those documents as email attachments and assign to MailMessage object.

muhammad raazaPosted Dec 28, 2022, 11:57 AM
Brillient work GOD bless you i have a question can you help me please
RaviTeja KandukuriPosted Dec 18, 2019, 6:30 AM
Done with dis, much thanks to you!
Chandhu YerramsettiPosted Dec 18, 2019, 6:27 AM
Nice, Can I use my outlook mail account for sending?
Yeela SinghPosted Dec 18, 2019, 6:25 AM
Nice sir, Thanks for Sharing
Sugun RoyPosted Dec 18, 2019, 6:23 AM
Nice article! worked like a charm
Sourav Kumar DasPosted Dec 17, 2019, 10:49 PM
Nice and useful article.
Ravishankar NPosted Dec 17, 2019, 10:46 AM
Nice article