%@ LANGUAGE = "VBScript" %>
<%
If Session("flag") = False Then Response.Redirect "tek9_login.asp"
Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adUseClient = 3
Set cnDZ = Server.CreateObject("ADODB.Connection")
cnDZ.Open "Data Source=//nawinfs02/home/users/web/b249/rh.sikh/database/eprodatabase;Provider=Microsoft.Jet.OLEDB.4.0;"
'set these 4 variables to anything you like:
'by default, we have set this to "Yes", but if you change this to "No", then the code will default to CDONTS
useASPMail = "Yes"
company_name = "Domain, Inc."
homepage_url = "www.domain.com"
email1 = "me@domain.com"
pg = Request.QueryString("pg")
mode = Request.QueryString("mode")
doit = Request.QueryString("doit")
specific = Request.QueryString("specific")
suxes = "
Successful!
Click here to return home..."
sorry = "Sorry, that is invalid. Please click your browser Back button."
Response.Expires = 0 %>
IntraNet
<% Set obBT = Server.CreateObject("MSWC.BrowserType")
If obBT.javascript = TRUE And obBT.majorver >= 4 Then
ask = " onClick='ask()'" %>
<% obBT.Close
Set obBT = Nothing
End If %>
<%
If pg = "" Then
Response.Write"IntraNet *
"&_
"Click here to view your live website."
Response.Write""&_
"| Newsletter: |
"
Set rs = cnDZ.Execute("SELECT ID, MY_EMAIL FROM TBLNEWSLETTER ORDER BY MY_EMAIL ASC")
If Not rs.EOF Then
Response.Write"
"
Response.Write"
"
ElseIf pg = "newsletter" Then
If mode = "new" Then
If doit = "" Then
Response.Write""
Else
FRMAT = Request.Form("TYPE")
PRIORITY = Request.Form("PRIORITY")
SUBJECT = Request.Form("SUBJECT")
MESSAGE = Request.Form("MESSAGE")
If Request.Form("FOOTER") = "on" Then FTR = "If you no longer wish to be a part of our monthly newsletter, please reply to this email with a blank message and UNSUBSCRIBE in the Subject line." Else FTR = ""
If useASPMail = "Yes" Then
'ASPMail(SMTPsvg.dll) is required to run this, so if you don't have ASPMail,
'it can be downloaded from www.serverobjects.com
Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
'enter the name of your mail server here:
Mailer.RemoteHost = "mail.mailserver.com"
Mailer.FromName = homepage_url
Mailer.FromAddress = email1
Mailer.AddRecipient "Newsletter subscriber", email1
Set rs = cnDZ.Execute("SELECT DISTINCT MY_EMAIL FROM TBLNEWSLETTER")
If Not rs.EOF Then
lastEmail = ""
Do Until rs.EOF
If lastEmail <> rs("MY_EMAIL") Then Mailer.AddBCC "Newsletter subscriber", Server.HTMLEncode(rs("MY_EMAIL"))
lastEmail = rs("MY_EMAIL")
rs.MoveNext
Loop
End If
rs.Close
Set rs = Nothing
Mailer.ContentType = ""&FRMAT&""
Mailer.Priority = PRIORITY
Mailer.Subject = SUBJECT
If FRMAT = "text/html" Then
Mailer.Bodytext = ""&MESSAGE&"
"&FTR&"
"
Else
Mailer.Bodytext = ""&MESSAGE&""&_
" "&VBCrLf&" "&_
""&FTR&""
End If
Mailer.SMTPLog = "C:\ASPMail.log"
If Mailer.SendMail Then Response.Write"
Newsletter Sent!
Click here to return home..." Else Response.Write"
Error!
The Newsletter was not sent correctly.
Click here to return home..."
Else
'begin the CDONTS method of sending out the newsletter:
Set objCDOMail = Server.CreateObject("CDO.message")
objCDOMail.From = email1
objCDOMail.To = email1
objCDOMail.Subject = SUBJECT
If FRMAT = "text/html" Then
objCDOMail.BodyFormat = 0
objCDOMail.MailFormat = 0
objCDOMail.TextBody = ""&MESSAGE&"
"&FTR&""
Else
objCDOMail.TextBody = ""&MESSAGE&""&vbCrLf&""&vbCrLf&""&FTR&""
End If
Set rs = cnDZ.Execute("SELECT DISTINCT MY_EMAIL FROM TBLNEWSLETTER")
If Not rs.EOF Then
lastEmail = ""
Do Until rs.EOF
If lastEmail <> rs("MY_EMAIL") Then objCDOMail.Bcc ""&Server.HTMLEncode(rs("MY_EMAIL"))&"; "
lastEmail = rs("MY_EMAIL")
rs.MoveNext
Loop
End If
rs.Close
Set rs = Nothing
If PRIORITY = "1" Then
impo = "2"
ElseIf PRIORITY = "5" Then
impo = "0"
Else impo = "1"
End If
objCDOMail.Importance = impo
objCDOMail.Send
Set objCDOMail = Nothing
End If
End If
ElseIf mode = "update" Then
If specific = "" Then
Set rs = cnDZ.Execute("SELECT * FROM TBLNEWSLETTER WHERE ID = "&Request.Form("ID")&"")
Response.Write""
rs.Close
Set rs = Nothing
Else
Set rsU = Server.CreateObject("ADODB.RecordSet")
rsU.Open "SELECT * FROM TBLNEWSLETTER WHERE ID = "&specific&"", cnDZ, adOpenStatic, adLockOptimistic
MY_EMAIL = Request.Form("MY_EMAIL")
If MY_EMAIL <> "" Then rsU.Fields("MY_EMAIL") = MY_EMAIL
rsU.Update
rsU.Close
Set rsU = Nothing
Response.Write suxes
End If
ElseIf mode = "delete" Then
sql = "DELETE * FROM TBLNEWSLETTER WHERE ID = "&specific&""
Set rs = cnDZ.Execute(sql)
Set rs = Nothing
Response.Write suxes
Else Response.Write sorry
End If
Else Response.Write sorry
End If %>
<% cnDZ.Close
Set cnDZ = Nothing %>