<% 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 %> <!--#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 arrID2 = split(arrIDM, ",") for i=0 to ubound(arrID2) strWhere = strWhere & "(ContactID = " & arrID2(i) & ") OR " next strWhere = left(strWhere, len(strWhere) -4) s = "SELECT strName, strEmail From tblContact WHERE " & strWhere set rst = cn.execute(s) while not rst.eof strMailto = strMailto & "<" & rst("strName") & ": " & rst("strEmail") & ">" rst.movenext wend rst.close x = swapIt(x) response.write "" response.write "" x = swapIt(x) response.write "" x = swapIt(x) response.write "" x = swapIt(x) response.write "" x = swapIt(x) response.write "" x = 0 x = swapIt(x) response.write "" response.write "" response.write "
Email Contacts
 
My Email Address:" x = swapIt(x) response.write "
Cc:" x = swapIt(x) response.write "
BCc:" x = swapIt(x) response.write "
Contact Recipients:" x = swapIt(x) response.write "
Subject:" x = swapIt(x) response.write "
Message:
Attachments
 
 
  
" %>
<% end if %>