Hello, I think you must need to check the code below which has used the namespace System.Web.Mail in the program for sending the mail.
Code:
using System;
using System.Web.Mail;
class Chekcing
{
static void Main(string[] args)
{
Chekcing.Test("[email protected]",
"[email protected]",
"Test Message",
"Hello World! ");
}
public static void Test(string From, string To, string Sub, string Body)
{
MailMessage msg = new MailMessage();
msg.From = From;
msg.To = To;
msg.Subject = Sub;
msg.BodyFormat = MailFormat.Text;
msg.Body = Body;
try
{
System.Console.WriteLine("Testing msg");
SmtpMail.Test(msg);
}
catch( System.Web.HttpException e )
{
System.Console.WriteLine("Exception occurred:" +e.Message);
}
}
}
Bookmarks