search
Japanese Chinese Nederlands Espanol Italiano Deutsch Francais Twitter Rss Feeds
MicrosoftArticlesForumsFAQs
C# .NET
VB.NET
Visual Studio .NET
ADO.NET
Xml / Xslt
VB 6.0
.NET CF
GDI+
LINQ
Deployment
Security
FoxPro
Silverlight / WPF
Entity Framework
RIA Services

Web ProgrammingArticlesForumsFAQs
JavaScript
ASP
ASP.NET
Web Services

Non-MicrosoftArticlesForumsFAQs
NHibernate
Perl
PHP
Ruby
Java
Linux / Unix
Apple
Open Source

DatabasesArticlesForumsFAQs
SQL Server
Access
Oracle
MySQL
Other Databases

OfficeArticlesForumsFAQs
Excel
Word
Powerpoint
Outlook
Publisher
Money

Operating SystemsArticlesForumsFAQs
Windows 7
Windows Server
Windows Vista
Windows XP
Windows Update
MAC
Linux / UNIX

Server PlatformsArticlesForumsFAQs
BizTalk
Site Server
Exhange Server
IIS

Graphic DesignArticlesForumsFAQs
Macromedia Flash
Adobe PhotoShop
Expression Blend
Expression Design
Expression Web

OtherArticlesForumsFAQs
Subversion / CVS
Ask Dr. Dotnetsky
Active Directory
Networking
Uninstall Virus
Job Openings
Product Reviews
Search Engines
Resumes

 

View Other Visual Studio .NET Posts   Ask New Question 
automatic email sending in asp.net using c#
Naveen Kumar posted at Friday, August 08, 2008 12:44 AM

hai,

how to send automatic email sending , like job alerts mail will be send .

i have to check with in 5 days if the user is not rated an automatic mail has to be send to his email.how to do

thanking you ,

Naveen


 
use Windows service for this...
Vasanthakumar D replied to Naveen Kumar at Friday, August 08, 2008 12:57 AM

Hi,

you can use windows service for this...

1. Create a widnows service

2. set timer for particluar time

3. write you functionality in time eplased event fo the timer.

 

 
Use this...
Atul Shinde replied to Naveen Kumar at Friday, August 08, 2008 1:02 AM

I think You have stored the data in you database. After 5 days you can put that code while your system starts. or you can use your Sql Server triggering technique. As trigger fires on the sql server side. It will send the message to the user. You can write that stored procedure to send mail.

Other technique is that u can create a web service and deploy that service on your mail server. As, this service is instantly running it will check data time of system (SERVER) and sends mail to the user.

 
  Auto Email
Kalit Sikka replied to Naveen Kumar at Friday, August 08, 2008 1:03 AM

protected bool mSendMail()

{

string strText = "YourText "

 

try

{

MailMessage mail = new MailMessage();

 

mail.To ="address@domain.com";

mail.Cc = cc@domain.com;

mail.From = Author@domain.com;

mail.Subject = "Auto Generated Mail - Software Requirement from " + DDept.Text;

string MailBody = string.Format("Requirement from: {0} <br><br> Delivery Date: {1} <br><br> Type of Requirements: {2} <br><br> Requirement Details: {3} <br><br> Contact Person: {4} <br><br> Contact Manager: {5}", txtUserName.Text, txtDeliveryDate.Text, DType.Text, txtARequir.Value, txtContactPerson.Text, DManager.Text);

mail.Body = strText + MailBody;

mail.BodyFormat = MailFormat.Html;

for (int i = 0; i < attachments.Count; i++)

{

mail.Attachments.Add(new MailAttachment(attachments[i]));

}

 

SmtpMail.SmtpServer="YourDomainSMTPServer";

SmtpMail.Send(mail);

return true;

}catch(Exception ex)

{

string strMessage = "<script language=JavaScript>alert('Unable to make Connection with local Mail Server '+ "+ex.ToString()+")</Script>";

Page.RegisterStartupScript("WinScript", strMessage);

return false;

}

}

 
check here...
egg egg replied to Naveen Kumar at Friday, August 08, 2008 1:03 AM

Check this link which is explaining similar requirement..

You can follow the inputs from here togo ahead with your requirement

http://www.sitepoint.com/article/sending-web-email-asp-net

 
automatic email sending in asp.net using c#
Sakshi a replied to Naveen Kumar at Friday, August 08, 2008 1:11 AM

1. The following is the code to send mail.

add reference to System.Web.dlll

add

using System.Web.Mail;

then you can use  the

a) MailMessage Object
b) SmtpMail Object

somthing like this

                                MailMessage mvMail= new MailMessage();
                        mvMail.To  ="itsumapathyk@gmail.com";
                        mvMail.From  =itsumapathyk@gmail.com;
                        mvMail.Body="test";
                        mvMail.Subject = "test s";
Must Note:
You have to specify the a valid  SmtpServer for this to work and you must have the rights on this server

                        SmtpMail.SmtpServer  = "bslnt";
                        SmtpMail.Send(mvMail);

2. Create a windows application with this code

3.  add a scheduler to scheduled task and set the specific time you want it to run.

 
  Use WINDOWS SERVICE
Sujit Patil replied to Naveen Kumar at Friday, August 08, 2008 1:30 AM

For that you have to Use WINDOWS SERVICE.

Its easy just go thr these steps;    

1.Open Visual Studio.net > Select New Project 

     2.Select Windows Service and give Name as 'GoodDay' and Click Ok.

     3.Right Click the Design and Select Properties and give the Name and ServiceName as 

        'GoodDay' and set AutoLog to 'True'

     4.Drag and drop the OleDbConnection and Select its properties and change its name to

        'conn' and provide the connection String(I provided the Database sample(Ms

         Access)) along with this code.

     5.Right Click the Design and select View Code and

        Select Project > Add Reference > Select System.Web >Press Ok

     6.Now add the following to your code         

          using System.Web.Mail;

          using System.Data.OleDb;

     7.Declare DateTime mdt=DateTime.Now;

     8.    In static void Main()

         Edit the following Code

        ServicesToRun = new System.ServiceProcess.ServiceBase[] { new GoodDay() };

     9. Edit the following code in onstart()

         DataSet ds = new DataSet();

protected override void OnStart(string[] args)

{

DateTime dt=DateTime.Now;

conn.Open();

OleDbDataAdapter da=new OleDbDataAdapter("select * from Empdata",conn);

da.Fill(ds);

if(dt.ToShortDateString()==mdt.ToShortDateString())

{

foreach(DataRow dr in ds.Tables[0].Rows)

{

mdt=DateTime.Now.AddDays(+1);

String mailtxt="";

MailMessage mm = new MailMessage();

mm.BodyFormat = MailFormat.Html;

mm.To = dr["emp_email"].ToString();

mm.From = "xyz@xyz.com";

mm.Subject="Good Day";

mailtxt = "<font face='verdana' color='#FF9900'><b>"+"Hi "+dr["emp_name"].ToString()+"," + "</b></font><br><br>";

mailtxt=mailtxt+"<font face='verdana' color='#FF0000'><b>"+"Good Day." + "</b></font><br><br>";

mailtxt=mailtxt+"<font face='verdana' color='#008080'><b>"+"May today be filled with sunshine and smile, laughter and love." + "</b></font><br><br>";

mailtxt=mailtxt+"<font face='verdana' color='#0000FF'><b>Cheers!" + "<br><br>";

mm.Body = mailtxt;

SmtpMail.SmtpServer="localhost";

SmtpMail.Send(mm);

}

}

}

10.Go to Design,right click and Select Add Installer ,you will notice two controls

     serviceProcessInstaller1,serviceInstaller1

11.Select  serviceProcessInstaller1 and go to its properties and change the Account

      type to 'Local System'

12. Select  serviceInstaller1 and go to its properties and change DisplayName and

      ServiceName to 'GoodDay' and make the StartType to 'Automatic'

13.Build the Solution(Cntrl+Shift+B)

14.Open the Visual Studio .Net Command Prompt and give the path of application

     for example C:\bin\Debug and then type InstallUtil GoodDay.exe
                

     to uninstall,  InstallUtil    /u GoodDay.exe         

15. After Installation ,right click My Computer and

       Select 'Manage'

       and Select 'Service and Applications'

       and in that Select 'Services'

Select 'GoodDay' and start the Service.

Best Luck!!!!!!!!!!!!!!!!!
Sujit.

 
thanks to all for helpin coding
Naveen Kumar replied to Sujit Patil at Friday, August 08, 2008 1:55 AM
thanks to all ,
 
check this
sri sri replied to Naveen Kumar at Friday, August 08, 2008 3:21 AM
Hi,
you can try using the sql scheduler to send mails.

create a new job in the sql management . this will run as per the scheduling.

 
automatic mail sending using windows service(source code in c#)
jatin jatin replied to Naveen Kumar at Wednesday, March 04, 2009 3:08 AM

i need code in c# for send mail from database using on server time

this require like reminder so please help me