Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#GimmeCode
how to send mail everyday evening 7pm using c# code please send me the c# code
Posted 9-Sep-12 23:45pm
Edited 10-Sep-12 1:44am
Wes Aday61.3K
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Hello,
 
Quickest way to implement requested fynationality, You can write console application using C# which contain SMTP host and credential details in app.config file. class file will contain logic to send email as below :
 
using System;
using System.Collections.Generic;
using System.Text;
using System.Net.Mail;
using System.Net;

class Program
{
static void Main(string[] args)
{
Console.WriteLine("Mail To");
MailAddress to = new MailAddress(Console.ReadLine());

Console.WriteLine("Mail From");
MailAddress from = new MailAddress(Console.ReadLine());

MailMessage mail = new MailMessage(from, to);

Console.WriteLine("Subject");
mail.Subject = Console.ReadLine();

Console.WriteLine("Your Message");
mail.Body = Console.ReadLine();

SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;

smtp.Credentials = new NetworkCredential(
"username@domain.com", "password");
smtp.EnableSsl = true;
Console.WriteLine("Sending email...");
smtp.Send(mail);
}
 

After creation of .EXE file, Please just schedule task using scheduler with Requested frequency.
  Permalink  

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 840
1 OriginalGriff 437
2 Abhinav S 303
3 thatraja 225
4 Emre Ataseven 200
0 Sergey Alexandrovich Kryukov 8,122
1 OriginalGriff 4,520
2 Peter Leow 3,744
3 Maciej Los 3,515
4 Er. Puneet Goel 3,107


Advertise | Privacy | Mobile
Web03 | 2.8.140415.2 | Last Updated 10 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid