Jump to content

Unable to detect zip file


ur
 Share

Recommended Posts

I got a UDF to zip the files from below link.

With this I am able to create a zip file but the post processing of zip file creation I am checking the zip file exists or not, but it is giving the message as file not found.

 

Any sugestions??

#include "Zip.au3"

ZipLogs()

Func ZipLogs()
    $ResultsFolder = @ScriptDir & "\Results"
    $ResultsDestFolder = @ScriptDir & "\Results_Archive"
    $zipFile = $ResultsDestFolder & "\Results_"&TodayDateTime()&".zip"

    DirCreate($ResultsDestFolder)

    Dim $Zip = _Zip_Create($zipFile) ;Create The Zip File. Returns a Handle to the zip File
    _Zip_AddFolderContents($Zip, $ResultsFolder) ;Add a folder's content in the zip file

    if FileExists(@ScriptDir&"\Logging.log") then
        _Zip_AddFile($Zip,@ScriptDir&"\Logging.log")
        FileDelete(@ScriptDir&"\Logging.log")
    EndIf

    if FileExists(@ScriptDir&"\RemoteExecution_Log.txt") then
        _Zip_AddFile($Zip,@ScriptDir&"\RemoteExecution_Log.txt")
        FileDelete(@ScriptDir&"\RemoteExecution_Log.txt")
    EndIf

    if FileExists($zipFile) then
        DirRemove($ResultsFolder,$DIR_REMOVE)
    Else
        MsgBox(0,"","Zip file not found")
    EndIf

    return $zipFile
EndFunc

 

Zip.au3

Link to comment
Share on other sites

The _ZIP* functions set macro @error when there was a problem. So you should check this macro after having called a _ZIP* function.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

@water

Sorry the info is not correct earlier,

the file is able to detect with file exists.

But when I pass that file name to the below code.

Dim $zip_file = ZipLogs()

if FileExists($zip_file) then
    MsgBox(0,"",$zip_file)
    SendAutoMail("AutoIT:Install Testing Process","Testing of Installers completed","PFA: attached log files",$zip_file)
Else
    SendAutoMail("AutoIT:Install Testing Process","Testing of Installers completed","Log files not found to attach")
EndIf

It is able to go the first branch of code as I am able to get the message prompt.

But I am not getting any email.

SendMail.au3

I am able to get the mail if I pass some other attachments for testing.

Can you suggest for this.

Link to comment
Share on other sites

What I posted above is true for SendAutoMail as well. Check @error or the return value.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Please search the forum for _INetSmtpMailCom. IIRC this has beend discussed multiple times.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Add a COM error handler to your script to get more detailed error information. Easiest way is to use the Debug UDF:

#include <Debug.au3>
_DebugSetup()
_DebugCOMError()

... Your script goes here ...

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

When I tried to pass the zip file to the mail function after the zipping is done, it is giving return code 2.

But if I try again as a separate au3 file by sending the zip file as argument later, it is sending.

So I tried whether file is in use or not by below code but I am geting the second message stating that file is not in use.

#include "SendMail.au3"
$f = @TempDir&"\logs.zip"

$filename = $f
    if FileInUse($filename) Then
        MsgBox(0, "", "File is in use")
    Else
        MsgBox(0, "", "Not in use - go nuts")
        SendAutoMail("AutoIT:Install Testing Process","Testing of Installers completed","PFA: attached log files",$f)
    EndIf

;SendAutoMail("AutoIT:Install Testing Process","Got the Installers","Will intimate once the process is completed",$f)
;SendAutoMail("AutoIT:Install Testing Process","Testing of Installers completed","PFA: attached log files",$f)

Func FileInUse($filename)
    $handle = FileOpen($filename, 1)

    $result = False
    if $handle = -1 then $result = True

    FileClose($handle)

    return $result
EndFunc

Any idea??

Link to comment
Share on other sites

@water , YeahI tried many links but no resolution for this.

 

I am getting below error while sending mail..

---------------------------
sendmail error: 2
---------------------------
The message could not be sent to the SMTP server. The transport error code was 0x80040217. The server response was not available
---------------------------
OK  
---------------------------
 

I have already enabled less secure app setting in gmail.

Link to comment
Share on other sites

Searching the web for "SMTP transport error code 0x80040217" returns a lot of hits.
One names a wrong username/password as the culprit.
http://stackoverflow.com/questions/9157087/getting-error-transport-error-code-was-0x80040217-while-sending-email-in-asp-net

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Can you verify that all variables still have the correct value before sending?
I once re-used a variable for something different and hence a function call crashed.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...