khawkins96
asked on
Need to add attachment to Windows Script File written using VBScript
I have inherited a web application (.NET) that uses a Windows Script File to generate an email every Friday to managers when their contract worker's contract is expiring. The WSF uses VBScript and now the business owner of the app wants to attach a Word document to the email. How do I go about adding that document to the WSF? Thanks!
ASKER
Thanks for responding! Here's a snipet! If you need more, please let me know. Thanks for looking at it!
<script language="VBScript">
Set Mail = CreateObject("Persits.Mail Sender")
mail.Host = "atnascom02.nasco.local"
mail.FromName="Contingent Workforce"
mail.From="CW@nasco.com"
set ReportToSet = CreateObject("ADODB.Record set")
set COntractSet = CreateObject("ADODB.Record set")
lcsql="select distinct contract_ReporttoNum from CTC_Contract where Contract_enddate>='" & date & "' and Contract_enddate<='" & dateadd("d",14,Date) & "' order by contract_reportToNum desc"
'WScript.Echo Lcsql
ReportToSet.Open lcsql,conn,3,3
'WScript.Echo reportToset.RecordCount
'WScript.Echo "Test"
while not ReportToSet.EOF
'WScript.Echo "running"
lcsql="select * from CTC_contract,dir_directory where Contract_ReporttoNum=empid and Contract_enddate>'" & date & "' and Contract_enddate<='" & dateadd("d",14,Date) & "' and contract_reportTonum=" & cint(reportToset.Fields("c ontract_Re portToNum" ))
'WScript.Echo Lcsql
COntractSet.Open lcsql,conn
if not contractset.EOF then
if not isnull(COntractSet.Fields( "email")) then
emailTo=COntractSet.Fields ("email")
mail.AddAddress emailto
mail.Subject="CW - Alert"
P_Body="1. The following contingent workforce will expire:" & chr(10)& chr(10)
while not contractset.EOF
contractname=contractset.F ields("con tract_Fnam e") & " " & contractset.Fields("contra ct_Lname")
Endnddate=contractset.Fiel ds("contra ct_EndDate ")
P_body=P_Body & "Name: " & contractname & chr(10)
P_body=P_Body & "End Date: " & endDate &chr(10) & chr(10)
contractset.MoveNext
wend
P_body=P_body & "2. If you are extending, then do not forget to change your item." & Chr(10) & Chr(10)& Chr(10) & Chr(10)
P_body=P_body & "3. On this individuals last day, it is your responsibility to collect the following items:" & chr(10) & Chr(10)
P_body=P_body & CHr(42) & "Security Access Card - return to Office Manager or Office Services Admin Asst"& chr(10) & Chr(10)
P_body=P_body & CHr(42) & "Key(s) - return to Office Manager"& chr(10) & Chr(10)
P_body=P_body & CHr(42) & "Confidential and business related documents and information - Hiring Manager to determine whether the documents will be saved or shredded"& chr(10) & Chr(10)
P_body=P_body & CHr(42) & "Other NASCO owned equipment (i.e. laptop - return to IS; headset - return to Office Services Coordinator)"& chr(10) & Chr(10)
mail.Body=P_Body
mail.AddBcc ("khawkins@nasco.com")
<script language="VBScript">
Set Mail = CreateObject("Persits.Mail
mail.Host = "atnascom02.nasco.local"
mail.FromName="Contingent Workforce"
mail.From="CW@nasco.com"
set ReportToSet = CreateObject("ADODB.Record
set COntractSet = CreateObject("ADODB.Record
lcsql="select distinct contract_ReporttoNum from CTC_Contract where Contract_enddate>='" & date & "' and Contract_enddate<='" & dateadd("d",14,Date) & "' order by contract_reportToNum desc"
'WScript.Echo Lcsql
ReportToSet.Open lcsql,conn,3,3
'WScript.Echo reportToset.RecordCount
'WScript.Echo "Test"
while not ReportToSet.EOF
'WScript.Echo "running"
lcsql="select * from CTC_contract,dir_directory
'WScript.Echo Lcsql
COntractSet.Open lcsql,conn
if not contractset.EOF then
if not isnull(COntractSet.Fields(
emailTo=COntractSet.Fields
mail.AddAddress emailto
mail.Subject="CW - Alert"
P_Body="1. The following contingent workforce will expire:" & chr(10)& chr(10)
while not contractset.EOF
contractname=contractset.F
Endnddate=contractset.Fiel
P_body=P_Body & "Name: " & contractname & chr(10)
P_body=P_Body & "End Date: " & endDate &chr(10) & chr(10)
contractset.MoveNext
wend
P_body=P_body & "2. If you are extending, then do not forget to change your item." & Chr(10) & Chr(10)& Chr(10) & Chr(10)
P_body=P_body & "3. On this individuals last day, it is your responsibility to collect the following items:" & chr(10) & Chr(10)
P_body=P_body & CHr(42) & "Security Access Card - return to Office Manager or Office Services Admin Asst"& chr(10) & Chr(10)
P_body=P_body & CHr(42) & "Key(s) - return to Office Manager"& chr(10) & Chr(10)
P_body=P_body & CHr(42) & "Confidential and business related documents and information - Hiring Manager to determine whether the documents will be saved or shredded"& chr(10) & Chr(10)
P_body=P_body & CHr(42) & "Other NASCO owned equipment (i.e. laptop - return to IS; headset - return to Office Services Coordinator)"& chr(10) & Chr(10)
mail.Body=P_Body
mail.AddBcc ("khawkins@nasco.com")
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Wonderful! Thank you for that info!
The question here is how are you sending your email now. There are a bunch of different ways you can do that, and they each probably have a method for sending an attachment. Can you post a snippet of code for the way you are sending the base e-mail now?