Click here to Skip to main content
15,912,329 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends

I need to send an Email Automatically everyday without performing any page click events..

I should never use Windows services also..

Guide me to overcome with this issue..

Thanks
Posted

1 solution

For this it needs at a single time to call your website anywhere or from any user.
Or for that you can set "Task Scheduler" to run a browser on a time. Mail send event should present on you page load event with check condition if not sent today mail yet then send.

Then maintain your status in database that mail is sent by datewise or not.
If already sent then no need to fire the event to send mail.

See you have to try this from your backend. If you are getting any problem everybody is here to help you. But this much idea you can implement that.
 
Share this answer
 
Comments
usha C 16-May-14 6:28am    
I tried working With my code using web services...

And the main code i have writen on Global.aspx page and backend action also Performed....

The code works good when i work on an Local

But When its run on server it doesn't work..

Pls Check My code

Global.aspx:

public Guid AppId = Guid.NewGuid();

public String TestMessage;

public String GetAppDescription(String eventName)
{
StringBuilder builder = new StringBuilder();

builder.AppendFormat("-------------------------------------------{0}", Environment.NewLine);
builder.AppendFormat("Event: {0}{1}", eventName, Environment.NewLine);
builder.AppendFormat("Guid: {0}{1}", AppId, Environment.NewLine);
builder.AppendFormat("Thread Id: {0}{1}", System.Threading.Thread.CurrentThread.ManagedThreadId, Environment.NewLine);
builder.AppendFormat("Appdomain: {0}{1}", AppDomain.CurrentDomain.FriendlyName, Environment.NewLine);
builder.AppendFormat("TestMessage: {0}{1}", TestMessage, Environment.NewLine);
builder.Append((System.Threading.Thread.CurrentThread.IsThreadPoolThread ? "Pool Thread" : "No Thread") + Environment.NewLine);

return builder.ToString();
}

void Application_Start(object sender, EventArgs e)
{
TestMessage = "Not Null";
// Code that runs on application startup
Trace.WriteLine(GetAppDescription("Application_Start"));

}

void Application_BeginRequest(object sender, EventArgs e)
{
CreateTimers();
}

private void CreateTimers()
{
Trace.WriteLine("TimerStarted at" + DateTime.Now + "<br/>");
System.Timers.Timer WebServiceTimer = new System.Timers.Timer();

WebServiceTimer.Enabled = true;
WebServiceTimer.Interval = (60000 * 1440);

WebServiceTimer.Elapsed += new System.Timers.ElapsedEventHandler(WebServiceTimer_Elapsed);
}

public void WebServiceTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
Trace.WriteLine("Timer_Elapsed at" + DateTime.Now + "<br/>");
Automate_EmailJobs objEmailJobs = new Automate_EmailJobs();
objEmailJobs.RunJob();
}

void Application_End(object sender, EventArgs e)
{
// Code that runs on application shutdown
Trace.WriteLine(GetAppDescription("Application_End"));
}

void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
Trace.WriteLine(GetAppDescription("Application_Error"));
}

void Session_Start(object sender, EventArgs e)
{
// Code that runs when a new session is started
Trace.WriteLine(GetAppDescription("Application_BeginRequest"));
}

void Session_End(object sender, EventArgs e)
{
// Code that runs when a session ends.
// Note: The Session_End event is raised only when the sessionstate mode
// is set to InProc in the Web.config file. If session mode is set to StateServer
// or SQLServer, the event is not raised.
Trace.WriteLine(GetAppDescription("Application_EndRequest"));
}

protected void Application_AuthenticateRequest(object sender, EventArgs e)
{
// look if any security information exists for this request
if(HttpContext.Current.User != null)
{
// see if this user is authenticated, any authenticated cookie (ticket) exists for this user
if (HttpContext.Current.User.Identity.IsAuthenticated)
{
// see if the authentication is done using FormsAuthentication
if (HttpContext.Current.User.Identity is FormsIdentity)
{
// Get the roles stored for this request from the ticket

// get the identity of the user
FormsIdentity identity = (FormsIdentity)HttpContext.Current.User.Identity;
[no name] 16-May-14 6:39am    
where is your mail send method
usha C 16-May-14 6:40am    
public class Automate_EmailJobs : System.Web.Services.WebService<br>
{<br>
ClsCommonBAL commonBAL = new ClsCommonBAL();<br>
EmailServices email = new EmailServices();<br>
 <br>
private static Mutex mute = new Mutex(false, "JobSchedulerMutex");<br>
<br>
[WebMethod]<br>
public bool RunJob()<br>
{<br>
bool ranJOb = false;<br>
mute.WaitOne();<br>
 <br>
try<br>
{<br>
TraceService("Service Reached RunJobs");<br>
//email.SendEmail("Alert Checking", "Scheduler alert checking", "Alert Triggered at " + DateTime.Now + "<br/>", "usha@gmail.com", 1); <br>
commonBAL.RunAllActiveJobs();<br>
ranJOb = true;<br>
}<br>
catch (Exception ex)<br>
{<br>
throw ex;<br>
}<br>
finally <br>
{<br>
mute.ReleaseMutex();<br>
}<br>
return ranJOb;<br>
}<br>
[no name] 16-May-14 6:52am    
why are you not using this email service to HOME page load event. EmailServices email = new EmailServices(); If application will run then email will send automatically
usha C 16-May-14 6:59am    
Even if the application not runs also i need to send email... so that only i have written in Global.aspx

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