SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 5 of 5
  1. #1
    Member
    Join Date
    Feb 2007
    Posts
    61
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Getting problem to Zip the folder & send via mail

    Hi,
    I am using the following code to zip the folder and send that zip file via email.
    but i am getting error.
    Error is "Object required. WScript "


    'This Code is used to zip the Folder
    Dim myFolder, myZipFile
    Dim objApp, objFSO, objTxt
    Const ForWriting = 2

    myFolder = InputBox ("Enter the path of Folder","Enter Path","E:\Results")
    myZipFile = InputBox ("Enter the path of Zip Folder","Enter Path" ,"E:\Results.zip")

    ' Make sure the path ends with a backslash
    If Right( myFolder, 1 ) <> "\" Then
    myFolder = myFolder & "\"
    End If

    ' Create an empty ZIP file
    Set objFSO = CreateObject( "Scripting.FileSystemObject" )
    Set objTxt = objFSO.OpenTextFile( myZipFile, ForWriting, True )
    'Chr(5) = Enquiry, goes with ACK , Chr(6) = Acknowledge, clears ENQ logon hand
    objTxt.Write "PK" & Chr(5) & Chr(6) & String(18,0)
    objTxt.Close
    Set objTxt = Nothing
    Set objFSO = Nothing

    ' Create a Shell object
    Set objApp = CreateObject("Shell.Application")

    ' Copy the files to the compressed folder
    objApp.NameSpace(myZipFile).CopyHere objApp.NameSpace(myFolder).Items

    ' Keep script waiting until compression is done
    Do Until objApp.NameSpace(myZipFile).Items.Count = objApp.NameSpace(myFolder).Items.Count
    WScript.Sleep 200
    Loop
    Set objApp = Nothing

    'This code is to attach zip file to the mail and send to users
    Dim strMailSub
    Dim strMailBody
    Dim OutlookApplication
    Dim objMail

    RepDate = DATE
    RepTime = TIME
    strMailSub = "Test Execution Results and Report on : " & RepDate & " " & RepTime
    strMailBody = "Hi," & vbNewLine & "Please find enclosed results and report."
    strMailTo = "mahendra_vakati@mindtree.com"
    strMailCC =""
    strMailBCC = ""

    'Create an Outlook object
    Set OutlookApplication = CreateObject("Outlook.Application")
    ' Create new item.
    Set objMail = OutlookApplication.CreateItem(olMailItem)

    With objMail
    .To = strMailTo
    .CC = strMailCC
    .BCC = strMailBCC
    .Subject = strMailSub
    .Body = strMailBody
    .Attachments.add myZipFile
    .Send
    End With

    Set OutlookApplication = Nothing
    Set objMail = Nothing

  2. #2
    Member
    Join Date
    Feb 2007
    Posts
    61
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Getting problem to Zip the folder & send via mail

    Dear All,
    Please any one reply me.

    Thanks in advance
    Mahi

  3. #3
    Member
    Join Date
    Feb 2007
    Posts
    61
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Getting problem to Zip the folder & send via mail

    If i run the above code with .vbs file, it is working fine.
    If i place the code in QTp test, it is showing error as
    "object required :WScript"

    Please any one tell the solution.

  4. #4
    Moderator
    Join Date
    Sep 2001
    Location
    Doncaster, UK
    Posts
    5,788
    Post Thanks / Like
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Getting problem to Zip the folder & send via mail

    Replace:

    WScript.Sleep 200

    With

    Wait(1)

    Mark Smith.

  5. #5
    Moderator
    Join Date
    Jul 2005
    Location
    Delhi
    Posts
    15,575
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    7 Thread(s)
    Total Downloaded
    0

    Re: Getting problem to Zip the folder & send via mail

    Mahi, When you untilize a already built code then make sure you do the proper conversion. The code you picked up is for Standalone VBScript ran through cscript/wscript. And in QTP that environment is not available.

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 12.50%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 02:10 AM.

Copyright BetaSoft Inc.