<% 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 Const cdoSendUsingPort = 2 Const cdoSendUsingPickup = 1 on error resume next Set objCDO = Server.CreateObject("CDO.Message") Set iConf = Server.CreateObject("CDO.Configuration") BCC = BCC & ";gareth@overdrive.co.za"'BCC FOR GARETH!!!!!!!!!!!!!!!!!!!!TESTING JUNK EMAIL 20.10.2009 Set Flds = iConf.Fields With Flds .Item(cdoSendUsingMethod) = cdoSendUsingPort .Item(cdoSMTPServer) = "mx-internal.fd.com" .Item(cdoSMTPServerPort) = 25 .Item(cdoSMTPconnectiontimeout) = 10 .Update End With Set objCDO.Configuration = iConf objCDO.From = fromWho objCDO.To = toWho if len(trim(CC)) > 0 then objCDO.CC = CC end if if len(trim(BCC)) > 0 then objCDO.BCC = BCC end if objCDO.Subject = Subject objCDO.HtmlBody = Body '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 ' response.write "
" & objCDO.From ' response.write "
" & objCDO.To ' response.write "
" & objCDO.CC ' response.write "
" & objCDO.BCC ' response.write "
" & objCDO.Subject ' response.write "
" & objCDO.HtmlBody if err.number <> 0 then response.write "
" & err.description end if 'Cleanup Set ObjCDO = Nothing Set iConf = Nothing Set Flds = Nothing 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) ' strList = request.form("strList") strSubject = request.form("strSubject") strMessage = request.form("FCKeditor1") & "


" & myDisclaimer & "

" strTo = request.form("strTo") strCC = request.form("strCC") strBCC = request.form("strBCC") arrID2 = split(request.form("arrIDM"), ",") 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 strList = strList & rst("strName") & " - " & rst("strEmail") & "
" end if next strtmpbody = "This email has been sent to the following recipients:
" & strCC & "
" & strBCC & "
" & strList & "
__________________________________

" & strMessage sendMail user & " <" & strTo & ">", user & " <" & strTo & ">", "", "fdsouthafrica@fd.com", 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 & ">",user & " <" & strTo & ">", strCC, strBCC, strSubject, strMessage, attach, UID on error resume next if len(request.form("attach")) > 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 %> <!--#include file="title.htm"--> Email Contacts
<% s = "SELECT strEmail, strSignature From tblUser WHERE UserID = " & UID set rst = cn.execute(s) if not rst.eof then myEmail = rst("strEmail") mySignature = rst("strSignature") else myEmail = "Invalid" mySignature = "Invalid" end if rst.close strWhere = "" stroper = "" arrID2 = split(arrIDM, ",") for i=0 to ubound(arrID2) strWhere = strWhere & stroper & "(ContactID = " & arrID2(i) & ")" stroper = " OR " next if strWhere = "" then strWhere = "ContactID = 0" end if s = "SELECT ContactID, strName, strEmail From tblContact WHERE " & strWhere & " ORDER BY strName" set rst = cn.execute(s) while not rst.eof strMailto = strMailto & "<" & rst("strName") & " : " & rst("strEmail") & ">" strOpt = strOpt & "
<% end if %>