Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Web Page Update Notification

Status
Not open for further replies.

MstrMitch

Programmer
Oct 23, 2000
10
0
0
US
Is there a way in ASP or perhaps a different technology to send out an email to certain email addresses when a web page has been changed or updated? any help would be appreciated
 
That depends on how you update your pages. If your site is mostly coming out of a database, it shouldn't be a problem. Everytime some content/record gets updated, you can have an automatic email sent to your users.
If you use FTP for example, it's going to be a different story, and as far as I know you will probably need some other technology other than ASP. :)



<webguru>iqof188</webguru>
 
how do I set up that automatic email to the users?
 
I suppose your server has CDO Mail (which comes with NT) installed. I presume you also have a table with the email addresses of the persons you want to notify of the changes.
Get ready, here's the code (place it in the page where you have your update-query for the DB with the content, right after the actual code to update your DB):


<%
Code to update you contenttable goes here
%>

<%
'First, lets get the connection
Set MyConn=Server.CreateObject(&quot;ADODB.Connection&quot;)
MyConn.Open &quot;PROVIDER=MSDASQL;&quot; &amp; _
&quot;DRIVER={Microsoft Access Driver (*.mdb)}; &quot; &amp; _
&quot;DBQ=&quot; &amp; server.mappath(&quot;MyDatabase.mdb&quot;)
MySQL=&quot;Select * from TableName&quot;
Set MyRs=MyConn.Execute(MySQL)

'Get the emailaddresses from the recordset and place them in a variable called MyVar:

MyRs.MoveFirst
MyVar= &quot;&quot;
delimiter = &quot;&quot;
do while not MyRs.eof
If Not IsNull(MyRs(&quot;email&quot;)) Then
MyVar= MyVar &amp; delimiter &amp; MyRs(&quot;email&quot;)
delimiter = &quot;; &quot;
End If
MyRs.movenext
loop

'Okay, we have the list of addresses now...
'Let's compose the body

MyBody=&quot;Our page has been updated&quot; &amp; vbcrlf &amp; _ &quot;Check it out at &amp; vbcrlf &amp; &quot;Have fun!&quot; &amp; vbcrlf &amp; &quot;MstrMitch&quot;

'Create the CDO Mail Object
Set objEmail = Server.CreateObject(&quot;CDONTS.NewMail&quot;)
objEmail.To=&quot;someone@somewhere.com&quot;
objEmail.From = &quot;MstrMitch@mydomain.com&quot;
objEmail.Subject = &quot;Update!!&quot;

'Send a blind carbon copy (Bcc) to all the addresses in the MyVar variable

objEmail.Bcc=myVar
objEmail.Body = MyBody
objEmail.Send

'Mail has been send, get rid of the objects
MyRs.close
Set MyRs= Nothing
MyConn.Close
set MyConn=nothing
Set objEmail=Nothing

%>

That's about it... ;-)

<webguru>iqof188</webguru>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top