Windows Service with Mailing concepts:-
- To send the mails SMTP protocol is required.
- The protocol provides a set of rules, which need to be followed while transferring the data over the network.
- Smtp will be installed by default when It is installed.
- When IIS is installed then the Following Folder Structure will be created by default.
EX: 2 on windows Service with mailing concepts:-
- Developing a service to send a mail at 12:30
- Open windows Service project with project name WS2
Project Menu Add Reference System .wed (this is required for Mail Message class) Place Timer (System .Timers )control Properties Enabled = true Interval = 60, 000 Interval 100ms w:30 12:30:00 01 1 sec = 600 .. 100ms = 60 … 1 60,000 59 60,000
Using System. web. Mail;
Code for Timer 1 _ Elapsed Event
Int sh =Date Time . Now. Hour ;
// 24 hrs format
Int sum = Date Time . Now. Minute;
If (sh == 12 && sm ==30)
Mail Message m = new Mail Message ();
M .to = “teja @ yahoo.com”; m.cc = “varoon @india.com”;
subject = “Happy Pongal”;
body Format = Mail Format. Html;
body = <h1>Happy pongal </h1> <hr>
<h2><Font color = Green> Dear Friends, This is to inform you that, our next class will be on 17th jan, 2009 </Font> </h2>”;
Form = “Prakash @ptpl”;
//ptpl is computer name Smtp Mail .Send (m);