Using System.Net.Mail namespace u can send mails.
Here is a code for this. You can use the same code to create a method with the parameters (specified variables) and call from any places.
The Mail ids, attachments are separated with comma (,).
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string SmtpServer = ConfigurationManager.AppSettings["App_Mail_Server"]; // Provide the SMTP server name
string strFrom = "abc@xyz.com";
string strTo = "cde@pqr.com,cde1@pqr1.com";
string strCC = "cde2@pqr4.com,cde3@pqr5.com";
string strBCC = "cde5@pqr3.com,cdew@pqrw.com";
string strPeriority = "High";
string strAttachment = @"C:\parent screen.jpg,C:\Print Screen.jpg";
string strSubject = "Test Mail with Multiple Attachment";
string strBody = "Test Mail with Multiple Attachment";
bool IsBodyIsInHTML = false;
try
{
SmtpClient smtp = new SmtpClient(SmtpServer);
MailMessage mssg = new MailMessage();
mssg.From = new MailAddress(strFrom);
mssg.Subject = strSubject;
mssg.Body = strBody;
//Adding multiple To Addresses
foreach (string sTo in strTo.Split(",".ToCharArray()))
mssg.To.Add(sTo);
//Adding multiple CC Addresses
foreach (string sCC in strCC.Split(",".ToCharArray()))
mssg.CC.Add(sCC);
//Adding multiple BCC Addresses
foreach (string sBCC in strBCC.Split(",".ToCharArray()))
mssg.Bcc.Add(sBCC);
//Adding multiple BCC Addresses
foreach (string sAttachment in strAttachment.Split(",".ToCharArray()))
{
Attachment attachment = new Attachment(sAttachment);
mssg.Attachments.Add(attachment);
}
MailPriority mailPeriority = MailPriority.Normal;
switch (strPeriority)
{
case "High":
mailPeriority = MailPriority.High;
break;
case "Low":
mailPeriority = MailPriority.Low;
break;
case "Normal":
mailPeriority = MailPriority.Normal;
break;
}
mssg.Priority = mailPeriority;
mssg.BodyEncoding = System.Text.Encoding.Default;
mssg.SubjectEncoding = System.Text.Encoding.Default;
mssg.IsBodyHtml = IsBodyIsInHTML;
smtp.Send(mssg);
}
catch (Exception ex)
{
//trach the exception and write in the log. might be Main Addresses contains non mail id formats.
}
}
}
}
Here is a code for this. You can use the same code to create a method with the parameters (specified variables) and call from any places.
The Mail ids, attachments are separated with comma (,).
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string SmtpServer = ConfigurationManager.AppSettings["App_Mail_Server"]; // Provide the SMTP server name
string strFrom = "abc@xyz.com";
string strTo = "cde@pqr.com,cde1@pqr1.com";
string strCC = "cde2@pqr4.com,cde3@pqr5.com";
string strBCC = "cde5@pqr3.com,cdew@pqrw.com";
string strPeriority = "High";
string strAttachment = @"C:\parent screen.jpg,C:\Print Screen.jpg";
string strSubject = "Test Mail with Multiple Attachment";
string strBody = "Test Mail with Multiple Attachment";
bool IsBodyIsInHTML = false;
try
{
SmtpClient smtp = new SmtpClient(SmtpServer);
MailMessage mssg = new MailMessage();
mssg.From = new MailAddress(strFrom);
mssg.Subject = strSubject;
mssg.Body = strBody;
//Adding multiple To Addresses
foreach (string sTo in strTo.Split(",".ToCharArray()))
mssg.To.Add(sTo);
//Adding multiple CC Addresses
foreach (string sCC in strCC.Split(",".ToCharArray()))
mssg.CC.Add(sCC);
//Adding multiple BCC Addresses
foreach (string sBCC in strBCC.Split(",".ToCharArray()))
mssg.Bcc.Add(sBCC);
//Adding multiple BCC Addresses
foreach (string sAttachment in strAttachment.Split(",".ToCharArray()))
{
Attachment attachment = new Attachment(sAttachment);
mssg.Attachments.Add(attachment);
}
MailPriority mailPeriority = MailPriority.Normal;
switch (strPeriority)
{
case "High":
mailPeriority = MailPriority.High;
break;
case "Low":
mailPeriority = MailPriority.Low;
break;
case "Normal":
mailPeriority = MailPriority.Normal;
break;
}
mssg.Priority = mailPeriority;
mssg.BodyEncoding = System.Text.Encoding.Default;
mssg.SubjectEncoding = System.Text.Encoding.Default;
mssg.IsBodyHtml = IsBodyIsInHTML;
smtp.Send(mssg);
}
catch (Exception ex)
{
//trach the exception and write in the log. might be Main Addresses contains non mail id formats.
}
}
}
}
For email attachment size problems, Thru offers an enterprise solution to securely and effortlessly send these files, without any change in workflow.
ReplyDeleteYou should check it out. Thru offers a great solution for email attachment managemnt.
http://www.thruinc.com/email-attachment-management/
Your source on Email Sending with Multiple Attachments is working great.
ReplyDeleteOkay Thanks !!!! Tamila
Deleteqtp training in chennai
ReplyDeleteWow! That's really great information guys.I know lot of new things here. Really great contribution.Thank you ...
ReplyDeletejava training in chennai
Thanks for sharing this informative blog. Keep update your blog.
ReplyDeleteJ2EE training in chennai
I feel really happy to have seen your webpage and look forward to so many more entertaining times reading here. Thanks once more for all the details.
ReplyDeleteBest selenium training Institute in chennai
This comment has been removed by the author.
ReplyDeleteThis is a nice post in an interesting line of content.Thanks for sharing this article, great way of bring this topic to discussion.
ReplyDeletejava training in annanagar | java training in chennai
java training in marathahalli | java training in btm layout
java training in rajaji nagar | java training in jayanagar
This comment has been removed by the author.
ReplyDeleteThis is very good content you share on this blog. it's very informative and provide me future related information.
ReplyDeleteangularjs-Training in velachery
angularjs-Training in annanagar
angularjs Training in chennai
angularjs Training in chennai
All the points you described so beautiful. Every time i read your i blog and i am so surprised that how you can write so well.
ReplyDeletepython online training
python training course in chennai
python training in jayanagar
It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...
ReplyDeleteSelenium online Training | Selenium Training in Pune | Selenium Training in Bangalore
You know what you’re talking about, why waste your intelligence on just posting videos to your blog when you could be giving us something enlightening to read?
ReplyDeletesafety course in chennai
I am definitely enjoying your website. You definitely have some great insight and great stories.
ReplyDeleteJava training in Bangalore | Java training in Marathahalli | Java training in Bangalore | Java training in Btm layout
Java training in Bangalore | Java training in Marathahalli | Java training in Bangalore | Java training in Btm layout
Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.
ReplyDeleteangularjs interview questions and answers
angularjs Training in bangalore
angularjs Training in bangalore
angularjs Training in chennai
automation anywhere online Training
Your site is amazing and your blog is informative. Share more like this.
ReplyDeleteccna Training in Chennai
ccna course in Chennai
AWS Training in Chennai
RPA Training in Chennai
DevOps Training in Chennai
Angularjs Training in Chennai
I have been searching for this information and got to know now. Thanks to the admin for sharing this blog.
ReplyDeleteBest English Classes in Bangalore
Best English Coaching Classes in Bangalore
English Speaking Classes in Bangalore
Best Spoken English Training in Bangalore
Spoken English Classes in Bangalore
Spoken English Class in Bangalore
Spoken English Training in Bangalore
Excellent post gained so much of information, Keep posting like this.
ReplyDeleteairport management courses in bangalore
airport management in bangalore
airline and airport management courses in bangalore
Air hostess academy Bangalore
I have to thank for sharing this blog, really helpful.
ReplyDeleteccna Training institute in Chennai
ccna institute in Chennai
Python Training in Chennai
Python course in Chennai
R Training in Chennai
R Programming Training in Chennai
CCNA Training in Velachery
CCNA Training in Tambaram
Amazing post thanks to read
ReplyDeleteCCNA training class in chennai
Do you mind if I quote a couple of your posts as long as I provide credit and sources back to your blog? My blog is in the same niche as yours, and my users would benefit from some of the information you provide here. Please let me know if this ok with you. Thank you.
ReplyDeletefire and safety course in chennai
This comment has been removed by the author.
ReplyDeleteIt is a great post. Keep sharing such kind of useful information.
ReplyDeleteenglishlabs
Guest posting sites
A good blog for the people who really needs information about this. Good work keep it up.
ReplyDeleteArticle submission sites
Guest posting sites
Nice Post! Thank you for sharing knowledge, it was very good post to update my knowledge and improve my skills. keep blogging.
ReplyDeleteJava Training in Electronic City
Merely a smiling visitant here to share the love (:, btw outstanding style. find personal email
ReplyDeleteHeyy! Checkout Our Reliable SMPP server platform is which specially designed for high-volume Bulk sms users.
ReplyDeleteHi,
ReplyDeleteGood job & thank you very much for the new information, i learned something new. Very well written. It was sooo good to read and usefull to improve knowledge. Who want to learn this information most helpful. One who wanted to learn this technology IT employees will always suggest you take python training in bangalore. Because Python course in Bangalore is one of the best that one can do while choosing the course.
Very good blog which explains really well about Selenium technology.
ReplyDeleteSAP Training in Chennai
AWS Training in Chennai
Java Training in Chennai
AWS Exam Center in Chennai
I am happy for sharing on this blog its awesome blog I really impressed. thanks for sharing. Great efforts.
ReplyDeleteLooking for Training Institute in Bangalore , India. Softgen Infotech is the best one to offers 85+ computer training courses including IT software course in Bangalore, India. Also it provides placement assistance service in Bangalore for IT.
Best Software Training Institute in Bangalore
superb....
ReplyDeleteinplant training in chennai for it
namibia web hosting
norway web hosting
rwanda web hosting
spain hosting
turkey web hosting
venezuela hosting
vietnam shared web hosting
I am really happy to say it’s an interesting post to read. I learn new information from your article; you are doing a great job. Keep it up
ReplyDeleteLearn Hadoop Training from the Industry Experts we bridge the gap between the need of the industry. Softgen Infotech provide the Best Hadoop Training in Bangalore with 100% Placement Assistance. Book a Free Demo Today.
Big Data Analytics Training in Bangalore
Tableau Training in Bangalore
Data Science Training in Bangalore
Workday Training in Bangalore
Very nice blog. interesting information.
ReplyDeleteonline data science training in bangalore
online data science with python training in bangalore
online data science course in bangalore
online react native training in bangalore
online react native course in bangalore
wondering information's about Studies and getting new innovative ideas Through this articles.Thanks for sharing your valuable Information's.
ReplyDeletepython training in chennai | python training in annanagar | python training in omr | python training in porur | python training in tambaram | python training in velachery
Excellent Blog. the blog is really Informative for the Beginners.
ReplyDeleteData Science Training Course In Chennai | Data Science Training Course In Anna Nagar | Data Science Training Course In OMR | Data Science Training Course In Porur | Data Science Training Course In Tambaram | Data Science Training Course In Velachery
I would like to say thank you for the amazing details and concepts you are sharing in this.The style of writing is excellent and also the content is top-notch.
ReplyDeleteDot Net Training in Chennai | Dot Net Training in anna nagar | Dot Net Training in omr | Dot Net Training in porur | Dot Net Training in tambaram | Dot Net Training in velachery
Its is very helpful for all of us and I never get bored while reading your article
ReplyDeletebecause, they are becomes a more and more interesting from the starting lines until the end.it is an awesome article i can learn more about devops. the way of presentation was so good
Data Science Training In Chennai
Data Science Online Training In Chennai
Data Science Training In Bangalore
Data Science Training In Hyderabad
Data Science Training In Coimbatore
Data Science Training
Data Science Online Training
Hi nice post one of the best blog to share here thank you for this blog
ReplyDeleteAI Training in Hyderabad
Sharing the same interest, Infycle feels so happy to share our detailed information about all these courses with you all! Do check them out
ReplyDeleteoracle training in chennai & get to know everything you want to about software trainings.
Study Amazon Web Services for making your career as a shining sun with Infycle Technologies. Infycle Technologies is the best AWS training institute in Chennai, providing complete hands-on practical training of professional specialists in the field. In addition to that, it also offers numerous programming language tutors in the software industry such as Oracle, Python, Big Dat, Hadoop, etc. Once after the training, interviews will be arranged for the candidates, so that, they can set their career without any struggle. Of all that, 200% placement assurance will be given here. To have the best career, call 7502633633 to Infycle Technologies and grab a free demo to know more.
ReplyDeleteTOP AWS TRAINING IN CHENNAI
Любой жаждет узнать свое будущее и воспринимает конкретные средства хиромантии более достоверными. Гадание на три карты это попытка предсказать грядущие действия постоянно завлекал человека. Предсказание будущего дозволяет просмотреть, что человека ожидает в предстоящем времени.
ReplyDeleteHere at this site is really a fastidious material collection so that everybody can enjoy a lot.
ReplyDeletedata analytics training in hyderabad
betmatik
ReplyDeletekralbet
betpark
mobil ödeme bahis
tipobet
slot siteleri
kibris bahis siteleri
poker siteleri
bonus veren siteler
RCEW
Informative post thanks for sharing
ReplyDeleteSai Satcharitra Pdf
Nice post thanks for sharing
ReplyDeletetoday gold rate namakkal
شركة عزل اسطح
ReplyDeleteعزل اسطح
شركة عزل اسطح
ReplyDeleteعزل اسطح
شركة مكافحة بق الفراش بالجبيل FM3RiWDOvd
ReplyDelete