Need to add attachment to Windows Script File written using VBScript

Posted on 2007-08-08
Last Modified: 2008-03-17
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!
Question by:khawkins96
    LVL 3

    Expert Comment

    Well, you could very easily use a helper tool like Blat:

    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?


    Author Comment

    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 ("")

    LVL 3

    Accepted Solution

    It looks like you are using ASPEmail to do the sending.  You can read more about attachments here:

    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.

    Author Comment

    Wonderful! Thank you for that info!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Suggested Solutions

    In this article we want to have a look at the directory attributes which are used by Microsoft to store the so called Security Identifiers (SID). These SIDs plays an important role in delegating and granting permissions and in authentication of trus…
    When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now