• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 368
  • Last Modified:

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!
  • 2
  • 2
1 Solution
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?

khawkins96Author Commented:
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"
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
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")
P_body=P_Body & "Name: " & contractname & chr(10)
P_body=P_Body & "End Date: " & endDate &chr(10) & chr(10)
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.AddBcc ("khawkins@nasco.com")

It looks like you are using ASPEmail to do the sending.  You can read more about attachments here: http://www.aspemail.com/manual_03.html

To send the attachment you will need to simply add a line like the following:
mail.AddAttachment "c:\temp\YourFile.doc"

obviously replacing the last part with your actual file you want to send.
khawkins96Author Commented:
Wonderful! Thank you for that info!

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now