HomeОбразованиеRelated VideosMore From: kudvenkat

Sending emails in asp.net using SMTP server settings from web config Part 78

187 ratings | 98030 views
Text version of the video http://csharp-video-tutorials.blogspot.com/2012/12/sending-emails-in-aspnet-using-smtp.html Slides http://csharp-video-tutorials.blogspot.com/2013/08/part-78-sending-emails-using-smtp.html All ASP .NET Text Articles http://csharp-video-tutorials.blogspot.com/p/free-aspnet-video-tutorial.html All ASP .NET Slides http://csharp-video-tutorials.blogspot.com/p/aspnet-slides.html All Dot Net and SQL Server Tutorials in English https://www.youtube.com/user/kudvenkat/playlists?view=1&sort=dd All Dot Net and SQL Server Tutorials in Arabic https://www.youtube.com/c/KudvenkatArabic/playlists In the previous session, we discussed about sending emails using asp.net. All the SMTP server settings were configured in code. In this session, we will discuss about specifying these settings in web.config file. Since the SMTP server settings are now configured in web.config. In code all you have to do is 1. Create an instance of the MailMessage class. Specify the FROM & TO email address, subject and Body 2. Create an instance of SmtpClient class, and send the email using Send() method. The SMTP settings will be automatically picked up from web.config file, when sending email. SendEmail() method code public static void SendEmail(string emailbody) { // Specify the from and to email address MailMessage mailMessage = new MailMessage ("[email protected]", "[email protected]"); // Specify the email body mailMessage.Body = emailbody; // Specify the email Subject mailMessage.Subject = "Exception"; // No need to specify the SMTP settings as these // are already specified in web.config SmtpClient smtpClient = new SmtpClient(); // Finall send the email message using Send() method smtpClient.Send(mailMessage); }
Html code for embedding videos on your blog
Text Comments (21)
pratick chakraborty (10 days ago)
Can we receive e-mail using asp.net c# ?
Syed Abid Ali Abdi (11 days ago)
Error : {"The remote certificate is invalid according to the validation procedure."} according to your coding i receive above error
VIBHU KHURANA (3 months ago)
which password is specified here?
Surinder Chaudhary (6 months ago)
sir getting error The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required......plz make a vedio on it how to solve it .
test piph005 (5 months ago)
Trzbne (8 months ago)
Wow! Venkat, thanks to You, I enjoy learning more than anything else! When I can chose learning or reading a book or listening to music, I rather chose your tutorials, because they are pure entertainment!
n bajra (1 year ago)
how we can send email for 465 port ? SmtpClient doesn't support port 465 ? Can you provide me tips , i will appreciate if you help me !!
concat weareawesome (1 year ago)
Hi Kudvenkat. Do i need to less my protection level in my gmail?
Fergus Tay (1 year ago)
hi, i need help on how to send gmail using asp.net. Whats the simplest way to code it?
Teja R (3 years ago)
Hi, I want to send multiple mail automattically, But one issue ill get mail as per the basis of the i want to send like, I will receive mail like for Example FROM: [email protected] TO:[email protected] BODY: mail contains ([email protected]) ->What i want to do means i want to take the [email protected] from the mail body. ->And write new mail for the TO:[email protected] with some mail looks like this for example: FROM: [email protected] TO:[email protected] Subject: Some things.   ->By automatically can possible do by mail server or any ways to do it. Please help me on this. Thanks in advance. Teja R
Ayse İnan (4 years ago)
I was afraid 7:20   :)
sadiq ullah (2 years ago)
why ayse Inan
MarinkoSpasojevic (4 years ago)
Dear Venkat, I have wrote your code and it works as a charm from my home. But in my school when I tried to start the same code I have problem, because my internal network is not allowing me to send mail on any address. In exception, where I catch why it's not sending, says just "Failure sending mail." which means nothing to me. I am almost 100% sure that my internal network is blocking me from connecting on gmail to send mail from that server. Any suggestion, I would appreciate a lot. I have watched all your videos on Asp, very good job, thank you a lot for all your work.
Leela Ram (4 years ago)
Thank you for this video. However, I need to know how to send multiple emails to different email addresses with unique attachment(pdf file) in each email. Should I create multiple instances of MailMessage class? Any thoughts would be helpful. I am planning to use SmtpClient class to send emails. 
Chris Scullion (5 years ago)
Venkat, Just want to say this is perhaps the most informative and well presented video tutorials I have had the pleasure of watching. Thank you very much and keep up the great work!
Mithun C (5 years ago)
Hi Venkat You have posted an excellent video on email. Can you please show how we can encrypt/Decrypt the user credentials in the application
akon villa (5 years ago)
Hai Brother, Plz Upload Retrieve Email from Gmail account in C# (or) Retrieve Email using pop3 in C#
kudvenkat (6 years ago)
Hi Thomas, for some reason your comments on this video are shown as removed. Do you see these comments any differently on this video.
Princess sara (2 years ago)
how can send for other domain like [email protected] or [email protected] etc help me about this thanks

Would you like to comment?

Join YouTube for a free account, or sign in if you are already a member.