|
-
Jun 14th, 2004, 10:03 PM
#1
Thread Starter
New Member
Sending email automatically?
Helo, how to automate sending email? I want to automatically send email to some addresses every day? How can i do that?
I build that one for my final project at my college. Please help me.
Thanks in advance.
I am using this code....
try
Dim objEmailMessage As System.Web.Mail.MailMessage
Dim objSMTPServer As System.Web.Mail.SmtpMail
objSMTPServer.SmtpServer = "mail.wefgroup.com"
objEmailMessage = New System.Web.Mail.MailMessage
With objEmailMessage
.To = "[email protected]"
.From = "[email protected]"
.Subject = "Helo"
.Body = "I test sending email"
End With
objSMTPServer.Send(objEmailMessage)
catch exc as exception
response.write(exc.innerexception.innerexception.message)
end try
Make A Project for Assignment using VB.Net and ASP.Net
-
Jun 15th, 2004, 04:15 AM
#2
Hyperactive Member
You could always just make a VB.NET exe and then schedule it under windows scheduler...
-
Jun 16th, 2004, 08:54 PM
#3
Thread Starter
New Member
Alternative ways?
Is there any alternatives to send email automatically other than Windows Scheduler?
Thanks...
Make A Project for Assignment using VB.Net and ASP.Net
-
Jun 16th, 2004, 08:57 PM
#4
PowerPoster
Start a timer when the web application starts up. Then, on fire, check the time, if it is the time to fire off the email, then do it, otherwise do nothing.
This is probably horribly inefficient though for a web app, not sure.
You could create a windows service, install it, and let it run in the background.
-
Jun 16th, 2004, 10:56 PM
#5
Thread Starter
New Member
helo, thanks for your reply.
How can i check whether the web application is started up?
I want the email send automatically everyday to the user...
How should i code it?
Make A Project for Assignment using VB.Net and ASP.Net
-
Jun 17th, 2004, 02:28 AM
#6
PowerPoster
Use the events in the Global.asax file.
I think Application Start is the one you want...not sure.
-
Jun 17th, 2004, 05:34 AM
#7
Thread Starter
New Member
Originally posted by hellswraith
Use the events in the Global.asax file.
I think Application Start is the one you want...not sure.
Thanks.
U mean all we need it just place the email code part at the Application Start in the Global.asax?
Make A Project for Assignment using VB.Net and ASP.Net
-
Jun 17th, 2004, 07:01 AM
#8
can you try this In your global.ascx
VB Code:
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the application is started
Dim myTimer As New System.Timers.Timer
myTimer.Interval = 5000
AddHandler myTimer.Elapsed, AddressOf myTimer_Elapsed
myTimer.Enabled = True
End Sub
Protected Sub myTimer_Elapsed(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs)
'run your code that determines if it time to send emails
'and if so call procedure/function that sends them
End Sub
Timer interval is in milliseconds so in your case you'll probably want it to be a lot bigger than 5000.
EDIT: I suppose you could even set the timer interval to 86400000 (1 day) but then you are relying on the server to be running 24 hours a day without any problems which isn't a good idea.
Last edited by Fishcake; Jun 17th, 2004 at 07:06 AM.
-
Jun 17th, 2004, 09:28 AM
#9
PowerPoster
EDIT: I suppose you could even set the timer interval to 86400000 (1 day) but then you are relying on the server to be running 24 hours a day without any problems which isn't a good idea.
This isn't a good idea for another reason possibly. ASP.NET apps will end if there is no activity. I don't know if having a timer going would prevent it from stopping or not. Only testing would expose everything.
-
Jun 22nd, 2004, 08:41 PM
#10
Frenzied Member
httpModule..?
What about an HttpModule? You install the module in the WebConfig
Code:
<httpModules>
<add name="Timer" type="TimerModule, TimerModule" />
</httpModules>
You inherit System.Web.IHttpModule(I think that's right.) and override OnBeginRequest? That means every request your OnBeginRequest is fired and whatever code is there runs. It needs to be fast. Super duper fast.
Magiaus
If I helped give me some points.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|