Visual Studio .NET - automatic email sending in asp.net using c#

Asked By Naveen Kumar
08-Aug-08 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...  use Windows service for this...

08-Aug-08 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...  Use this...

08-Aug-08 01: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  Auto Email

08-Aug-08 01: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...  check here...
08-Aug-08 01: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#  automatic email sending in asp.net using c#
08-Aug-08 01: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  Use WINDOWS SERVICE
08-Aug-08 01: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  thanks to all for helpin coding
08-Aug-08 01:55 AM
thanks to all ,
check this  check this
08-Aug-08 03: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#)  automatic mail sending using windows service(source code in c#)
04-Mar-09 03:08 AM

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

this require like reminder so please help me

  Swarnalaxmi replied to jatin jatin
30-Apr-10 12:14 AM
Using Windows service

Timer can given by intervel like Twice a day(12 hours once should run)
how can we give to run at exact time? (like 9am,9pm)
Thanks in advance
  Swarnalaxmi replied to Vasanthakumar D
30-Apr-10 12:15 AM
Using Windows service

Timer can given by intervel like Twice a day(12 hours once should run)
how can we give to run at exact time? (like 9am,9pm)
Thanks in advance
automatic email sending in asp.net using c#  automatic email sending in asp.net using c#
14-May-10 11:18 AM

 Hai,
  
    I want auto remainder mail using c# dot net (with source code fully) and demonstrate it .

   I sent complaint mail to my boss, within 2days he didnt rectify the task means automatically same datas fetch in database and send to boss . I dont know how to set remainder can you step by setp explain ..  
  arasu replied to Sakshi a
14-May-10 11:24 AM


 Hai,

  did u mention the sheduler explain it briefly.
automatic email system using asp.net  automatic email system using asp.net
03-Jan-11 08:23 PM

Hi,

I'm jeevalatha.........

i want a some of the sourcecode for automatic email system..........

Note:

          we are making payment to the vendors by ECS or NEFT.Once payment is made we need to communicate the vendor about the payment made.Currently this task is carried out by our traditional mailing system.

          I have to decide to automate this process by developing web application in asp.net....I think this new application will reduce the delay in communication with the vendor regarding the payment made.....And also reduce the paper work and dispatch work......

          I'm waiting for ur rly.......plz reply to me with in two days

  rakesh yadav replied to Naveen Kumar
11-Jan-12 01:27 AM
hi naveen
               how to uses the automatic job alerts email sending  how to uses the database and using c# any site plz send me link  
Create New Account
help
Visual Studio .net .NET Framework Hi NG, ich habe vor längerer Zeit mit Visual Studio .Net 2003 gearbeitet und überlege momentan auf einen neueren Stand upzudaten. Ein Visual Studio .Net 2008 scheint es nicht zu geben. Habe zumindest mit googeln nichts gefunden. Was
Wise for Visual Studio.NET Wise for Visual Studio.NET By Peter A. Bromberg, Ph.D. To "Print This Page" Link Peter Bromberg Wise for Visual Studio .NET is a total and complete installation development system for creating and editing Windows® Installer
Visual Studio versioning . . . . how to tell? .NET Framework To my knowledge, Visual studio 6 was released in 1998, then Visual Studio .NET 2002 is VS 7, then Visual Studio .NET 2003 is VS 7.1, then Visual
visual studio.net 2003 and Access 2007 database .NET Framework Hi I am currently using Visual Studio.Net 2003 running on Windows Server 2000 operating system. I have used Visual Studio.net 2003 connecting to Access 2002 databases in the pass with great success. Now
Is Visual Studio self-hosting ? .NET Framework Does Microsoft use Visual Studio IDE, Visual Studio Debugger, Visual Studio Linker and Visual Studio compiler for developing Visual Studio ? Or is Visual Studio not