%
if (isNull(request.cookies("ckyUserID"))) or (request.cookies("ckyUserID")="") then
response.redirect "index.asp"
end if
%>
<%
UID = clng(getUserID(request.cookies("ckyUserID")))
if len(request.querystring) > 0 then
QID = request.querystring("QID")
arrIDM = request.querystring("arrIDM")
else
QID = request.form("QID")
arrIDM = request.form("arrIDM")
end if
SUB sendmail( fromWho, toWho, CC, BCC, Subject, Body, attach, UID )
Dim objCDO
Dim iConf
Dim Flds
on error goto errHandle:
Const cdoSendUsingPort = 2
Set objCDO = Server.CreateObject("CDO.Message")
Set iConf = Server.CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
With Flds
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "CPTEX-1"
.Item(cdoSMTPServerPort) = 25
.Item(cdoSMTPconnectiontimeout) = 10
.Update
End With
Set objCDO.Configuration = iConf
objCDO.From = fromWho
objCDO.To = toWho
objCDO.CC = CC
objCDO.BCC = BCC
objCDO.Subject = Subject
objCDO.TextBody = Body
if attach <> 0 then
attach = split(left(attach, len(attach) -1), ";")
for j = 0 to ubound(attach)
objCDO.AddAttachment "C:\Inetpub\wwwroot\contacts\tmp_upload\" & UID & "_" & attach(j),,attach(j)
next
end if
objCDO.Send
'Cleanup
Set ObjCDO = Nothing
Set iConf = Nothing
Set Flds = Nothing
exit sub
errHandle:
Response.Write(Err.Description)
resume next
END SUB
if request.form("btnSend") = "Send" then
if request.form("attach") <> "" then
attach = request.form("attach")
else
attach = 0
end if
s = "Select strDisclaimer From tblSystem"
set rst = cn.execute(s)
if not rst.eof then
myDisclaimer = rst("strDisclaimer")
else
myDisclaimer = ""
end if
rst.close
user = getUserName(UID)
strBcc = request.form("strBcc")
strSubject = request.form("strSubject")
strMessage = request.form("strMessage") & chr(13) & myDisclaimer
strTo = request.form("strTo")
strCC = request.form("strCC")
strBCC = request.form("strBCC")
arrID2 = split(request.form("arrIDM"), ",")
strtmpbody = "This email has been sent to the following recipients:" & vbcrlf & strCC & vbcrlf & strBCC & vbcrlf & "__________________________________" & vbcrlf & vbcrlf & strMessage
sendMail user & " <" & strTo & ">", user & " <" & strTo & ">", "", "beachhead@bmsa.co.za; " & strBCC, strSubject, strtmpbody, attach, UID
for i = 0 to ubound(arrID2)
s = "SELECT strName, strEmail From tblContact WHERE ContactID = " & arrID2(i)
set rst = cn.execute(s)
if not rst.eof then
sendMail user & " <" & strTo & ">" ,rst("strName") & " <" & rst("strEmail") & ">" ,"", "", strSubject, strMessage, attach, UID
end if
next
sendMail user & " <" & strTo & ">", strCC,"", "", strSubject, strMessage, attach, UID
on error resume next
if len(request.form("attatch")) > 0 then
attach = split(left(request.form("attach"), len(request.form("attach")) -1), ";")
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
for i = 0 to ubound(attach)
fso.DeleteFile("C:\Inetpub\wwwroot\contacts\tmp_upload\" & UID & "_" & attach(i))
next
end if
response.write "The emails have been sent, you will receive a copy of each
Close this window"
response.end
elseif request.form("btnCancel") = "Cancel" then
response.redirect "runQuery.asp?QID=" & request.form("QID")
else
%>