PDA

View Full Version : Automated email with website update


JustAsking
12-08-2002, 11:54 PM
OK,

I have a question about mailing lists and informing mailing list people of updates to my website.

I have setup a mailing list which is connected to an Access database, where a visitor to my website can subscribe by entering their name, email address and select from check boxes their area of interest. I then proceed to manually send out an email to the subscribers information relating to what they selected as the area of interest.

Now, what I am working on is add the ability to have an email automatically sent to a mailing list subscriber when I add new or updated content to my website that relates to their area of interest.

For example John Doe, selects e-commerce and content management systems as his area of interest. Down the track I upload a new document or updated webpage with content relating to e-commerce or CMS. Once the page is uploaded an automated email is delivered to the mailbox of mailing list subscribers who selected that area of interest.

If anyone has seen or coded something similar to this could you please help me.

Mhtml
12-09-2002, 05:49 AM
Woah, heavy request ya got there..

Okey dokes I think the best way for this is to after updating a page just load a page which you can select what you just updated and then click a button to notify peeps..

Lets say you just update the e-commerce and content management systems section.

Now you goto the page updateAlerts.asp which would have something like this:

<%'updateAlerts.asp
If session("LoggedIn") = "true" then
'Do nothing
Else
Response.Redirect("login.asp")
end if
SectionName = Request.Form("SectionName")
Select Case SectionName
Case Section1
SectionUrl = "sectionone/sectionone.asp"
Case Section2
SectionUrl = "somewher/sectionne.html"
Case Else
SectionUrl = ""
End Select
If Len(SectionName) > 0 Then
DoSend = "true"
else
DoSend = "false"
End if
Select Case DoSend
Case "true"
Set conn = Server.CreateObject("Adodb.Connection")
conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ="&Server.MapPath("db/yourdb.mdb")&";"
Set rs = Server.CreateObject("Adodb.Recordset")
SqlGetUsers = "SELECT * From Table_Name WHERE SubscribedTo = '" & SectionName & "'"
rs.Open SqlGetUser, conn
If rs.eof then
response.write("There are no users subscribed to that section")
else
Set objCdonts = Server.CreateObject("Cdonts.NewMail")
Do while not rs.eof
objCdonts.From = "youremail@here.com"
objCdonts.To = rs("Email")
objCdonts.Subject = "www.yourdomain.com update"
objCdonts.bodyformat = 0
objCdonts.mailformat = 0
objCdonts.body = "Hello " & rs("Name") &"," & vbcrlf & "The section " & SectionName & "which you are subscribed to has just been updated! <a href="&chr(34)&"http://www.yourdomain.com/"&SectionUrl&chr(34)&">"&SectionName&"</a>"
objCdonts.send
set objCdonts = nothing
end if
Case else
response.redirect("login.asp")
End select
%>
<table>
<form action="updateAlerts.asp" method="post">
<tr><td><input type="radio" name="sectionName" value="section1" /></td><td>Section 1</td></tr>
<tr><td><input type="radio" name="sectionName" value="section2" /></td><td>Section 2</td></tr>
<tr><td><input type="radio" name="sectionName" value="section3" /></td><td>Section 3</td></tr>
<tr><td><input type="radio" name="sectionName" value="section4" /></td><td>Section 4</td></tr>
<tr><td><input type="radio" name="sectionName" value="section5" /></td><td>Section 5</td></tr>
<tr><td><input type="radio" name="sectionName" value="section6" /></td><td>Section 6</td></tr>
<tr><td colspan="2"><input type="submit" /></td></tr>
</form>
</table>


You will need to log in before you can do this though so use this ..
login.asp

<%'login.asp
if request.QueryString("i") = "doIt" Then
Select Case Request.Form("Password")
Case "Let_Me_In"
session("LoggedIn") = "true"
response.redirect("updatealerts.asp")
Case Else
session("LoggedIn") = "false"
End Select
%>
<form action="login.asp?i=doIt" method="post">
Password:<input type="password" name="Password" />
</form>


There is only minor validation in there so I guess you can improve on it...