Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to send mail using mail scheduler in vb.net by time ,Day/Month/year
Posted

here is code for send mail in C#.Net.

MailMessage message = new MailMessage();
SmtpClient smtpClient = new SmtpClient();

string msg = string.Empty;
try
{
MailAddress fromAddress = new MailAddress(from);
message.From = fromAddress;
message.To.Add("test@gmail.com");
if (ccList != null && ccList != string.Empty)
message.CC.Add("test@gmail.com");
message.Subject = subject;
message.IsBodyHtml = true;
message.Body = "Mail body";
smtpClient.Host = "smtp.gmail.com"; // We use gmail as our smtp client
smtpClient.Port = 587;
smtpClient.EnableSsl = true;
smtpClient.UseDefaultCredentials = true;
smtpClient.Credentials = new System.Net.NetworkCredential("yourmail@gmail.com", "password");

smtpClient.Send(message);
msg = "Successful";
}
catch (Exception ex)
{
msg = ex.Message;
}

this may help you.
 
Share this answer
 
 
Share this answer
 
you can create mail console application and scheduled it as per your requirement.
mail objects are available in .net
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900