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

  • دعنا نشارك هذا :
ترتيب الدرس : 78
المدة : 00:10:11
التحكم :
Text version of the video

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.


All ASP .NET Text Articles

All ASP .NET Slides

All Dot Net and SQL Server Tutorials in English

All Dot Net and SQL Server Tutorials in Arabic

In the previous session, we discussed about sending emails using 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
// Specify the email Subject

// 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

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

Sep 23, 2020 07:32:24