Sign in to follow this  
Followers 0
Tyranlol

Another Recursion Error

26 posts in this topic

Hai. this is my 'mailer' for my app. it mails errors and questions if the user wants. it runs in the background and checks for changes in the logfile containing path to a htm file that should be uploaded with the mail, but i keep getting recursion error after a few hours and i really can't figure out how to fix it.

#include<MyMail.au3>
#Include<file.au3>
IfFileExists()
Func IfFileExists()
    sleep(5000)
if fileexists(@scriptdir & "\list.txt") Then
    checkfile()
Else
    filewrite(@scriptdir & "\list.txt","")
    sleep(2000)
    checkfile()
EndIf
endfunc
Func Checkfile()
    While 1
        $file = FileOpen(@scriptdir & "\list.txt", 0)
    $chars = FileRead($file)
    FileClose($file)
    if $chars = "" Then
        sleep(30000)
    Else
        CheckInternet()
        exitloop
        endif
        wend 
    endfunc
    
    
    Func CheckInternet()
while 3 
$var = Ping("www.google.dk",250)
If $var then
    setsettings()
    exitloop
Else
sleep(30000)
endif
wend
endfunc
func setsettings()
global $sub = @computername
global $file1 = FileOpen(@scriptdir & "\list.txt", 0)
global $chars1 = FileRead($file1)
FileClose($file1)
mail()
endfunc
;###################
Func mail()
$SmtpServer = "smtp.gmail.com"
$FromName = "My Explorer"
$FromAddress = "MyMail@gmail.com"
$ToAddress = "MyMail@gmail.com"
$Subject = $sub
$Body = ""
$AttachFiles = $chars1
$CcAddress = "MyMail@gmail.com"
$BccAddress = "MyMail@gmail.com"
$Importance = "Normal"
$Username = "MyMail@gmail.com"
$Password = "MyPassword"
$IPPort =465
$ssl =1
;##################################
Global $oMyRet[2]
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
$rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl)
If @error Then
    Filewrite(@scriptdir & "\Errors.htm","<font face=Verdana size=1>")
   FileWrite(@scriptdir & "\Errors.htm","<br><BR>" & "<b>["& @computername &"]["& @Year&"."&@mon&"."&@mday&"  "&@HOUR & ":" &@MIN & ":" &@SEC & '] "Error code: ' & @error & '  Description: ' & $rc)
    iffileexists()
   Else
           If $chars1 <> "" Then
        Local $S_Files2Delete = StringSplit($chars1, ";")
        For $x = 1 To $S_Files2Delete[0]
                filedelete($S_Files2Delete[$x])
            Next
    endif
      FileDelete(@scriptdir & "\list.txt")
      iffileexists()
EndIf
endfunc

If any of you could spot anything that might be causing this recursion error or just have a tip, i'd like to hear. thanks in advance :)


[u]Only by Attempting the Impossible You Can Earn the Remarkable[/u]

Share this post


Link to post
Share on other sites



Tyranlol,

You need to replace the iffileexists() calls in the mail() function by Returns. Then you will unwind the recursion each time you get to that point. :)

To keep the script alive, you will need to put the initial iffileexists() call in a loop like this:

While 1
    iffileexists()
    Sleep(10)
WEnd

That should solve the problem. :)

Could I suggest the Recursion tutorial in the Wiki - it might help you from getting in the same pickle again. :P

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks for your answer Melba23.

I’m using the CheckFile and CheckInternet functions to check if new error file is available and whether user has internet or not. If not the user has internet it starts to sleep until user has internet, therefore I don't know the exact time between each functions.

Because of that I can't use the code below:

While 1
    iffileexists()
    Sleep(10)
wend

Any other ideas on how to keep the script alive? and thanks for the tip about Recursion tutorial, i'll read it :)

Edited by Tyranlol

[u]Only by Attempting the Impossible You Can Earn the Remarkable[/u]

Share this post


Link to post
Share on other sites

Tyranlol,

At the moment it is very difficult to offer advice as I have only the vaguest idea of what the script is doing at any point. Remember we do not know how you are using the script - to us it is just a series of lines. :)

In which function is your script idling and waiting for new input? It is that function that you need to put into a loop. Are you waiting until list.txt has some content? If so then something like this might do the trick:

#include<MyMail.au3>
#include<file.au3>

IfFileExists()

Func IfFileExists()
    Sleep(5000)

    ; Create the file if it does not exist
    If Not FileExists(@ScriptDir & "\list.txt") Then
        FileWrite(@ScriptDir & "\list.txt", "")
        Sleep(2000)
    EndIf
    ; Now start checking if there is any content
    checkfile()
EndFunc   ;==>IfFileExists

Func Checkfile()
    While 1
        ; Check if the file contains data
        If FileGetSize((@ScriptDir & "\list.txt") > 0 Then
            ; If it does check the internet
            CheckInternet()
            ExitLoop
        EndIf
        ; If not then wait a bit and look again
        Sleep(30000)
    WEnd
EndFunc   ;==>Checkfile

You will still need the Returns where I suggested so that everything unwinds. :P

Does that help? :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Thanks again for your answer Melba.

That's correct, my main application writes a path ex. "C:\Errors.htm" into list.txt and this application sends the file once list.txt has some text in it.

If list.txt is empty, then it'll start a sleep(30000) loop untill text is found. The CheckInternet function also uses the sleep loop if not user has internet connection

I'll try to implement your code and see if it works. And sorry for my code being a mess :)

Edited by Tyranlol

[u]Only by Attempting the Impossible You Can Earn the Remarkable[/u]

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Hmm. but i still need a way to keep the script going after it succesfully sent a mail ? :)

Here's my code as it looks now:

#include<MyMail.au3>
#Include<file.au3>
#notrayicon
IfFileExists()

Func IfFileExists()
    Sleep(5000)
    ; Create the file if it does not exist
    If Not FileExists(@ScriptDir & "\list.txt") Then
        FileWrite(@ScriptDir & "\list.txt", "")
        Sleep(2000)
    EndIf
    ; Now start checking if there is any content
    checkfile()
EndFunc   ;==>IfFileExists

Func Checkfile()
    While 1
        ; Check if the file contains data
        If FileGetSize(@ScriptDir & "\list.txt") > 0 Then
            ; If it does check the internet
            CheckInternet()
            ExitLoop
        EndIf
        ; If not then wait a bit and look again
        Sleep(30000)
    WEnd
EndFunc   ;==>Checkfile
    
    
Func CheckInternet()
;Check whether user has internet connection or not
while 3 
$var = Ping("www.google.dk",250)
If $var then
    SetSettings()
    exitloop
Else
sleep(30000)
Endif
WEnd
EndFunc   ;==>CheckInternet

Func SetSettings()
; Sets the settings for the mail, computername, file etc.
global $sub = @computername
global $file1 = FileOpen(@scriptdir & "\list.txt", 0)
global $chars1 = FileRead($file1)
FileClose($file1)
mail()
EndFunc   ;==>Set Settings

;###################
Func mail()
;Sends the mail and restarts the process
$SmtpServer = "smtp.gmail.com"
$FromName = "My Explorer"
$FromAddress = "MyMail@gmail.com"
$ToAddress = "MyMail@gmail.com"
$Subject = $sub
$Body = ""
$AttachFiles = $chars1
$CcAddress = "MyMail@gmail.com"
$BccAddress = "MyMail@gmail.com"
$Importance = "Normal"
$Username = "MyMail@gmail.com"
$Password = "MyPassword"
$IPPort =465
$ssl =1
;##################################
Global $oMyRet[2]
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
$rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl)
If @error Then
;If Mail fails then:
    Filewrite(@scriptdir & "\Errors.htm","<font face=Verdana size=1>")
   FileWrite(@scriptdir & "\Errors.htm","<br><BR>" & "<b>["& @computername &"]["& @Year&"."&@mon&"."&@mday&"  "&@HOUR & ":" &@MIN & ":" &@SEC & '] "Error code: ' & @error & '  Description: ' & $rc)
Return
   Else
;Deletes the error file(s) that has just been sent.
           If $chars1 <> "" Then
        Local $S_Files2Delete = StringSplit($chars1, ";")
        For $x = 1 To $S_Files2Delete[0]
                filedelete($S_Files2Delete[$x])
            Next
    endif
;Deletes the list file for re-creation at function IfFileExists()
      FileDelete(@scriptdir & "\list.txt")
Return
EndIf
EndFunc   ;==>Mail

Thanks again.

Edited by Tyranlol

[u]Only by Attempting the Impossible You Can Earn the Remarkable[/u]

Share this post


Link to post
Share on other sites

Tyranlol,

i still need a way to keep the script going after it succesfully sent a mail ?

So create a new empty file after you have deleted the old one in function mail() and remove the ExitLoop after you call CheckInternet().

Now you will stay in function Checkfile() and only call CheckInternet() if the file has text added to it. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Aha, i see. smart :)

So, something like:

#include<MyMail.au3>
#Include<file.au3>
CheckFile()
Func Checkfile()
    While 1
        ; Check if the file contains data
        If FileGetSize(@ScriptDir & "\list.txt") > 0 Then
            ; If it does check the internet
            CheckInternet()
        Sleep(15000)
        EndIf
        ; If not then wait a bit and look again
        Sleep(30000)
    WEnd
EndFunc   ;==>Checkfile
    
    
    Func CheckInternet()
while 3 
$var = Ping("www.google.dk",250)
If $var then
    setsettings()
    exitloop
Else
sleep(30000)
endif
wend
endfunc
func setsettings()
global $sub = @computername
global $file1 = FileOpen(@scriptdir & "\list.txt", 0)
global $chars1 = FileRead($file1)
FileClose($file1)
mail()
EndFunc   ;==>Set Settings

;###################
Func mail()
;Sends the mail and restarts the process
$SmtpServer = "smtp.gmail.com"
$FromName = "My Explorer"
$FromAddress = "MyMail@gmail.com"
$ToAddress = "MyMail@gmail.com"
$Subject = $sub
$Body = ""
$AttachFiles = $chars1
$CcAddress = "MyMail@gmail.com"
$BccAddress = "MyMail@gmail.com"
$Importance = "Normal"
$Username = "MyMail@gmail.com"
$Password = "MyPassword"
$IPPort =465
$ssl =1
;##################################
Global $oMyRet[2]
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
$rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl)
If @error Then
    Filewrite(@scriptdir & "\Errors.htm","<font face=Verdana size=1>")
   FileWrite(@scriptdir & "\Errors.htm","<br><BR>" & "<b>["& @computername &"]["& @Year&"."&@mon&"."&@mday&"  "&@HOUR & ":" &@MIN & ":" &@SEC & '] "Error code: ' & @error & '  Description: ' & $rc)
Return
   Else
           If $chars1 <> "" Then
        Local $S_Files2Delete = StringSplit($chars1, ";")
        For $x = 1 To $S_Files2Delete[0]
                filedelete($S_Files2Delete[$x])
            Next
    endif
      FileDelete(@scriptdir & "\list.txt")
      sleep(1000)
    FileWrite(@ScriptDir & "\list.txt", "")
Return
EndIf
EndFunc   ;==>Mail
Edited by Tyranlol

[u]Only by Attempting the Impossible You Can Earn the Remarkable[/u]

Share this post


Link to post
Share on other sites

Tyranlol,

I reckon that should do it. :)

A couple of points: :)

- You do not need to open/close the file to read it in setsettings().

- You might like to implement a counter in CheckInternet() so that you do not stay in there for ever if you do not get a return from your Ping after a few attempts.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Tyranlol,

I reckon that should do it. :)

A couple of points: :P

- You do not need to open/close the file to read it in setsettings().

- You might like to implement a counter in CheckInternet() so that you do not stay in there for ever if you do not get a return from your Ping after a few attempts.

M23

Thanks for all your help Melba23.

Time for testing! :)

Edited by Tyranlol

[u]Only by Attempting the Impossible You Can Earn the Remarkable[/u]

Share this post


Link to post
Share on other sites

Tyranlol

Thanks for all your help Melba35

Who is he? :)

M23 :)


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Tyranlol

Who is he? :)

M23 :)

Aha, sorry. Fixed! :P


[u]Only by Attempting the Impossible You Can Earn the Remarkable[/u]

Share this post


Link to post
Share on other sites

Aha, sorry. Fixed! :)

Don't apologize, Melba hasn't been 23 (or 35) since a loooong time ago!

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Oh yeah? Who is this then?

Posted Image

Caught you this time :)

Edited by Mat

Share this post


Link to post
Share on other sites

PsaltyDS,

Melba hasn't been 23 (or 35) since a loooong time ago

Oh, you know how the truth hurts! :)

But as my old Mum always says: "You are as old as you feel and as young as your joints will let you be!" So that makes me about 110 on a bad day! :)

M23 (+ a great many more)


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Hey Melba23, i hope you stil here!

I keep getting the recursion error after a few hours...

Here's my code as it looks now:

#include<MyMail.au3>
#Include<file.au3>
CheckFile()
Func Checkfile()
    If Not FileExists(@scriptdir & "\list.txt") Then 
        FileWrite(@ScriptDir & "\list.txt", "")
        sleep(1000)
        EndIf
    While 1
        ; Check if the file contains data and user has internet acces
        $var = Ping("www.google.dk",250)
        If FileGetSize(@ScriptDir & "\list.txt") > 0 and $var then
            ; If it does start SetSettings()
        SetSettings()
        Sleep(15000)
        EndIf
        ; If not then wait a bit and look again
        Sleep(30000)
    WEnd
EndFunc   ;==>Checkfile


Func SetSettings()
global $sub = @computername
global $file1 = FileOpen(@scriptdir & "\list.txt", 0)
global $chars1 = FileRead($file1)
FileClose($file1)
Mail()
EndFunc   ;==>Set Settings

;###################
Func Mail()
;Sends the mail with error-file
$SmtpServer = "smtp.gmail.com"
$FromName = "Error Manager"
$FromAddress = "MyMail@gmail.com"
$ToAddress = "MyMail@gmail.com"
$Subject = $sub
$Body = ""
$AttachFiles = $chars1
$CcAddress = "MyMail@gmail.com"
$BccAddress = "MyMail@gmail.com"
$Importance = "Normal"
$Username = "MyMail@gmail.com"
$Password = "MyPassword"
$IPPort =465
$ssl =1
;##################################
Global $oMyRet[2]
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
$rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl)
If @error Then
               If $chars1 <> "" Then
        Local $S_Files2Check = StringSplit($chars1, ";")
        For $x = 1 To $S_Files2Check[0]
                 If Not FileExists($S_Files2Check[$x]) then
                     $error = "1"
                Filewrite(@scriptdir & "\Errors.htm","<font face=Verdana size=1>")
                FileWrite(@scriptdir & "\Errors.htm","<br><BR>" & "<b>["& @computername &"]["& @Year&"."&@mon&"."&@mday&"  "&@HOUR & ":" &@MIN & ":" &@SEC & '] "File Not Found: ' & $S_Files2Check[$x] & '  Description: Specified file(s) in list.txt not found. No files exept list.txt has been changed.')
            Else
                Filewrite(@scriptdir & "\Errors.htm","<font face=Verdana size=1>")
                FileWrite(@scriptdir & "\Errors.htm","<br><BR>" & "<b>["& @computername &"]["& @Year&"."&@mon&"."&@mday&"  "&@HOUR & ":" &@MIN & ":" &@SEC & '] "Mailer has crashed, eventho the reason is unknown, the error code might grant you some help: ' & @error & '  Description: ' & $rc)
                EndIf
            Next
            If $error = "1" Then
            $RandomNumber = random(1,1000)
                FileCopy(@scriptdir & "\list.txt",@scriptdir & "\List_Old" & $randomnumber & ".txt")
                Sleep(500)
                FileDelete(@scriptdir & "\list.txt")
                sleep(500)
                FileWrite(@ScriptDir & "\list.txt", "")
            Endif
            Endif
Return
   Else
           If $chars1 <> "" Then
        Local $S_Files2Delete = StringSplit($chars1, ";")
        For $x = 1 To $S_Files2Delete[0]
                filedelete($S_Files2Delete[$x])
            Next
    endif
    FileDelete(@scriptdir & "\list.txt")
    sleep(1000)
    FileWrite(@ScriptDir & "\list.txt", "")
Return
EndIf
EndFunc   ;==>Mail

Just tell me if the code seems messy and i'll sort it out or explain what it does.

I really hope you can see where its going wrong :S

thanks in advance.


[u]Only by Attempting the Impossible You Can Earn the Remarkable[/u]

Share this post


Link to post
Share on other sites

Tyranlol,

I have just run the basic loop - that is the script you posted with all the functions but not the action lines other than the file wrting/deleting - 2,000,000 times without any recursion errors, so I am pretty sure that the problem lies elsewhere. :)

What is this MyMail.au3 include file you are using? Did you get it from the forum? If not, can you post it so I can take a look? :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

I don't remember the author of the script, but it is from this forum :)

P.S thanks for writing it if you read this post!

MyMail.au3:

Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Importance="Normal", $s_Username = "", $s_Password = "", $IPPort = 25, $ssl = 0)
    Local $objEmail = ObjCreate("CDO.Message")
    $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>'
    $objEmail.To = $s_ToAddress
    Local $i_Error = 0
    Local $i_Error_desciption = ""
    If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress
    If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress
    $objEmail.Subject = $s_Subject
    If StringInStr($as_Body, "<") And StringInStr($as_Body, ">") Then
        $objEmail.HTMLBody = $as_Body
    Else
        $objEmail.Textbody = $as_Body & @CRLF
    EndIf
    If $s_AttachFiles <> "" Then
        Local $S_Files2Attach = StringSplit($s_AttachFiles, ";")
        For $x = 1 To $S_Files2Attach[0]
            $S_Files2Attach[$x] = _PathFull($S_Files2Attach[$x])
;~          ConsoleWrite('@@ Debug : $S_Files2Attach[$x] = ' & $S_Files2Attach[$x] & @LF & '>Error code: ' & @error & @LF) ;### Debug Console
            If FileExists($S_Files2Attach[$x]) Then
                ConsoleWrite('+> File attachment added: ' & $S_Files2Attach[$x] & @LF)
                $objEmail.AddAttachment($S_Files2Attach[$x])
            Else
                ConsoleWrite('!> File not found to attach: ' & $S_Files2Attach[$x] & @LF)
                SetError(1)
                Return 0
            EndIf
        Next
    EndIf
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer
    If Number($IPPort) = 0 then $IPPort = 25
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort
    ;Authenticated SMTP
    If $s_Username <> "" Then
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password
    EndIf
    If $ssl Then
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
    EndIf
    ;Update settings
    $objEmail.Configuration.Fields.Update
    ; Set email Importance
    Switch $s_Importance
        Case "High"
            $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "High"
        Case "Normal"
            $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Normal"
        Case "Low"
            $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Low"
    EndSwitch
    $objEmail.Fields.Update
    ; Sent the Message
    $objEmail.Send
    If @error Then
        SetError(2)
        Return $oMyRet[1]
    EndIf
    $objEmail=""
EndFunc   ;==>_INetSmtpMailCom
;
;
; Com Error Handler
Func MyErrFunc()
    $HexNumber = Hex($oMyError.number, 8)
    $oMyRet[0] = $HexNumber
    $oMyRet[1] = StringStripWS($oMyError.description, 3)
    ConsoleWrite("### COM Error !  Number: " & $HexNumber & "   ScriptLine: " & $oMyError.scriptline & "   Description:" & $oMyRet[1] & @LF)
    SetError(1); something to check for when this function returns
    Return
EndFunc   ;==>MyErrFunc
Edited by Tyranlol

[u]Only by Attempting the Impossible You Can Earn the Remarkable[/u]

Share this post


Link to post
Share on other sites

Bump :)


[u]Only by Attempting the Impossible You Can Earn the Remarkable[/u]

Share this post


Link to post
Share on other sites

Tyranlol,

I still see no reason why you get a recursion error. What is the exact error message that you get? :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
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
Sign in to follow this  
Followers 0