How to send email via the system.web.mail class in ASP.Net?

You can send email using the system.web.mail class in your ASP.NET project, use the below sample code. you can refer to more details about the system.web.mail class here.

<% @Page Language=”C#” %>
<% @Import Namespace=”System.Web.Mail” %>
<%
MailMessage msgMail = new MailMessage();
// Receiver’s email address … 
msgMail.To = “Recipient Email Address”;
// Sender’s email address … 
msgMail.From = “Sender’s email address”;
// Subject line of email … 
msgMail.Subject = “Subject of an email”;
// Body format – HTML or TEXT … 
msgMail.BodyFormat = MailFormat.Text;
// Content of your email … 
msgMail.Body = “Body contents”;
// If you want to add attachments, use this line … 
msgMail.Attachments.Add(new MailAttachment(“c:\shane.xls”));
// Following 3 lines are used for SMTP Authentication … 
msgMail.Fields.Add(“http://schemas.microsoft.com/cdo/configuration/smtpauthenticate”, “1”); 
msgMail.Fields.Add(“http://schemas.microsoft.com/cdo/configuration/sendusername”, YOUR EMAIL ADDRESS); 
msgMail.Fields.Add(“http://schemas.microsoft.com/cdo/configuration/sendpassword”, YOUR EMAIL ACCOUNT PASSWORD);
SmtpMail.Send(msgMail);
Tagged : /

How to enable ASP.Net core stdout error logs?

Are you facing An error occurred while starting the application, start-up frailer in ASP.NET core? You need to check the error logs file to trace out the exact issue. KLCWEB study deeply into .NET core application’s error to provide the best solution.

1.) find our your site root folder from your hosting space.

2.) open web.config file > find aspnetCore > stdout and make it true as mention the below.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="dotnet" arguments=".\DotNetCoreApp.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
    </system.webServer>
  </location>
</configuration>

Once you have done this, you need to restart your application pool and refresh your site, The error log file will be generated inside logs folder which is located inside your site root folder, make sure you have created a logs folder before generating logs.

Tagged :