Link to home
Start Free TrialLog in
Avatar of khawkins96
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!
Avatar of tim_mcgue
tim_mcgue

Well, you could very easily use a helper tool like Blat:  http://www.blat.net/

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?

Avatar of khawkins96

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.MailSender")
mail.Host = "atnascom02.nasco.local"
mail.FromName="Contingent Workforce"
mail.From="CW@nasco.com"
            
set ReportToSet = CreateObject("ADODB.Recordset")
set COntractSet = CreateObject("ADODB.Recordset")
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("contract_ReportToNum"))
                  '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.Fields("contract_Fname") & " " & contractset.Fields("contract_Lname")
Endnddate=contractset.Fields("contract_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")

                  
ASKER CERTIFIED SOLUTION
Avatar of tim_mcgue
tim_mcgue

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Wonderful! Thank you for that info!