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

  • دعنا نشارك هذا :
ترتيب الدرس : 78
المدة : 00:10:11
التحكم :
Text version of the video
http://csharp-video-tutorials.blogspot.com/2012/12/sending-emails-in-aspnet-using-smtp.html

Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
https://www.youtube.com/channel/UC7sEwIXM_YfAMyonQCrGfWA/?sub_confirmation1

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?view1&sortdd

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 mailMessagenew MailMessage
("[email protected]", "[email protected]");
// Specify the email body
mailMessage.Bodyemailbody;
// Specify the email Subject
mailMessage.Subject"Exception";

// No need to specify the SMTP settings as these
// are already specified in web.config
SmtpClient smtpClientnew SmtpClient();
// Finall send the email message using Send() method
smtpClient.Send(mailMessage);
}

سيتم تفعيل التعليقات قريبا

y
Sep 23, 2020 07:32:24
youtube