Jump to content

I have one error ?


Recommended Posts

Sorry for distrub you but i have this script:

$s_SmtpServer = "smtp.lycos.co.uk"  ; Serveur POP : pop.lycos.co.uk 
$s_FromName = "nicolas"
$s_FromAddress = "xxxxxx@caramail.com"
$s_ToAddress = "xxxxxx@hotmail.fr"
$s_Subject = "test sent"
$as_Body = "sent"
$s_AttachFiles = @ScriptDir & '\test.txt'
$s_CcAddress = ""
$s_BccAddress = ""
$s_Username = "nicolas"
$s_Password = "xxxxxx
Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, $s_AttachFiles, $s_CcAddress, $s_BccAddress, $s_Username, $s_Password, $IPPort=25, $ssl=0)
    $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.Cc = $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])
            If FileExists($S_Files2Attach[$x]) Then
                $objEmail.AddAttachment ($S_Files2Attach[$x])
            Else
                $i_Error_desciption = $i_Error_desciption & @lf & 'File not found to attach: ' & $S_Files2Attach[$x]
                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
    $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
; Sent the Message
    $objEmail.Send
    if @error then 
        SetError(2)
        return $oMyRet[1]
    EndIf
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

But when I start the script, it works but send nothing, it's like that i start a script without anything inside...

What is the problem?

Thx for your replys :D

Edited by nico666
Link to comment
Share on other sites

But when I start the script, it works but send nothing, it's like that i start a script without anything inside...

What is the problem?

well, your're not calling _INetSmtpMailCom() anywhere in the script. Either that's the problem or you did not post the whole script.

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

Ok I post you all the script:

#NoTrayIcon
#include <GUIConstants.au3>
; == GUI generated with Koda ==
$Update = GUICreate("test", 270, 74, 415, 271, -1, BitOR($WS_EX_TOOLWINDOW,$WS_EX_TOPMOST,$WS_EX_STATICEDGE))
$Progress1 = GUICtrlCreateProgress(16, 48, 233, 15)
GUICtrlSetTip(-1, "100")
$Update = GUICtrlCreateLabel("test", 0, 16, 267, 18, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUISetState(@SW_SHOW)

sleep(40)
GUICtrlSetData($Progress1, 1)

;===============================================================================
$s_SmtpServer = "smtp.lycos.co.uk"  ; Serveur POP : pop.lycos.co.uk 
$s_FromName = "nicolas"
$s_FromAddress = "xxxxx@caramail.com"
$s_ToAddress = "xxxxx@hotmail.fr"
$s_Subject = "test"
$as_Body = "test"
$s_AttachFiles = @ScriptDir & '\test.txt
$s_CcAddress = ""
$s_BccAddress = ""
$s_Username = "nicolas"
$s_Password = "xxxxx"
Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, $s_AttachFiles, $s_CcAddress, $s_BccAddress, $s_Username, $s_Password, $IPPort=25, $ssl=0)
    $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.Cc = $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])
            If FileExists($S_Files2Attach[$x]) Then
                $objEmail.AddAttachment ($S_Files2Attach[$x])
            Else
                $i_Error_desciption = $i_Error_desciption & @lf & 'File not found to attach: ' & $S_Files2Attach[$x]
                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
    $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
; Sent the Message
    $objEmail.Send
    if @error then 
        SetError(2)
        return $oMyRet[1]
    EndIf
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   

;===============================================================================
sleep(40)
GUICtrlSetData($Progress1, 2)
sleep(40)
GUICtrlSetData($Progress1, 3)
sleep(40)
GUICtrlSetData($Progress1, 4)
sleep(40)
GUICtrlSetData($Progress1, 5)
sleep(40)
GUICtrlSetData($Progress1, 6)
sleep(40)
GUICtrlSetData($Progress1, 7)
sleep(40)
GUICtrlSetData($Progress1, 8)
sleep(40)
GUICtrlSetData($Progress1, 9)
sleep(40)
GUICtrlSetData($Progress1, 10)
sleep(40)
GUICtrlSetData($Progress1, 11)
sleep(40)
GUICtrlSetData($Progress1, 12)
sleep(40)
GUICtrlSetData($Progress1, 13)
sleep(40)
GUICtrlSetData($Progress1, 14)
sleep(40)
GUICtrlSetData($Progress1, 15)
sleep(40)
GUICtrlSetData($Progress1, 16)
sleep(40)
GUICtrlSetData($Progress1, 17)
sleep(40)
GUICtrlSetData($Progress1, 18)
sleep(40)
GUICtrlSetData($Progress1, 19)
sleep(40)
GUICtrlSetData($Progress1, 20)
sleep(40)
GUICtrlSetData($Progress1, 21)
sleep(40)
GUICtrlSetData($Progress1, 22)
sleep(40)
GUICtrlSetData($Progress1, 23)
sleep(40)
GUICtrlSetData($Progress1, 24)
sleep(40)
GUICtrlSetData($Progress1, 25)
sleep(40)
GUICtrlSetData($Progress1, 26)
sleep(40)
GUICtrlSetData($Progress1, 27)
sleep(40)
GUICtrlSetData($Progress1, 28)
sleep(40)
GUICtrlSetData($Progress1, 29)
sleep(40)
GUICtrlSetData($Progress1, 30)
sleep(40)
GUICtrlSetData($Progress1, 31)
sleep(40)
GUICtrlSetData($Progress1, 32)
sleep(40)
GUICtrlSetData($Progress1, 33)
sleep(40)
GUICtrlSetData($Progress1, 34)
sleep(40)
GUICtrlSetData($Progress1, 35)
sleep(40)
GUICtrlSetData($Progress1, 36)
sleep(40)
GUICtrlSetData($Progress1, 37)
sleep(40)
GUICtrlSetData($Progress1, 38)
sleep(40)
GUICtrlSetData($Progress1, 39)
sleep(40)
GUICtrlSetData($Progress1, 40)
sleep(40)
GUICtrlSetData($Progress1, 41)
sleep(40)
GUICtrlSetData($Progress1, 42)
sleep(40)
GUICtrlSetData($Progress1, 43)
sleep(40)
GUICtrlSetData($Progress1, 44)
sleep(40)
GUICtrlSetData($Progress1, 45)
sleep(40)
GUICtrlSetData($Progress1, 46)
sleep(40)
GUICtrlSetData($Progress1, 47)
sleep(40)
GUICtrlSetData($Progress1, 48)
sleep(40)
GUICtrlSetData($Progress1, 49)
sleep(40)
GUICtrlSetData($Progress1, 50)
sleep(40)
GUICtrlSetData($Progress1, 51)
sleep(40)
GUICtrlSetData($Progress1, 52)
sleep(40)
GUICtrlSetData($Progress1, 53)
sleep(40)
GUICtrlSetData($Progress1, 54)
sleep(40)
GUICtrlSetData($Progress1, 55)
sleep(40)
GUICtrlSetData($Progress1, 56)
sleep(40)
GUICtrlSetData($Progress1, 57)
sleep(40)
GUICtrlSetData($Progress1, 58)
sleep(40)
GUICtrlSetData($Progress1, 59)
sleep(40)
GUICtrlSetData($Progress1, 60)
sleep(40)
GUICtrlSetData($Progress1, 61)
sleep(40)
GUICtrlSetData($Progress1, 62)
sleep(40)
GUICtrlSetData($Progress1, 63)
sleep(40)
GUICtrlSetData($Progress1, 64)
sleep(40)
GUICtrlSetData($Progress1, 65)
sleep(40)
GUICtrlSetData($Progress1, 66)
sleep(40)
GUICtrlSetData($Progress1, 67)
sleep(40)
GUICtrlSetData($Progress1, 68)
sleep(40)
GUICtrlSetData($Progress1, 69)
sleep(40)
GUICtrlSetData($Progress1, 70)
sleep(40)
GUICtrlSetData($Progress1, 71)
sleep(40)
GUICtrlSetData($Progress1, 72)
sleep(40)
GUICtrlSetData($Progress1, 73)
sleep(40)
GUICtrlSetData($Progress1, 74)
sleep(40)
GUICtrlSetData($Progress1, 75)
sleep(40)
GUICtrlSetData($Progress1, 76)
sleep(40)
GUICtrlSetData($Progress1, 77)
sleep(40)
GUICtrlSetData($Progress1, 78)
sleep(40)
GUICtrlSetData($Progress1, 79)
sleep(40)
GUICtrlSetData($Progress1, 80)
sleep(40)
GUICtrlSetData($Progress1, 81)
sleep(40)
GUICtrlSetData($Progress1, 82)
sleep(40)
GUICtrlSetData($Progress1, 83)
sleep(40)
GUICtrlSetData($Progress1, 84)
sleep(40)
GUICtrlSetData($Progress1, 85)
sleep(40)
GUICtrlSetData($Progress1, 86)
sleep(40)
GUICtrlSetData($Progress1, 87)
sleep(40)
GUICtrlSetData($Progress1, 88)
sleep(40)
GUICtrlSetData($Progress1, 89)
sleep(40)
GUICtrlSetData($Progress1, 90)
sleep(40)
GUICtrlSetData($Progress1, 91)
sleep(40)
GUICtrlSetData($Progress1, 92)
sleep(40)
GUICtrlSetData($Progress1, 93)
sleep(40)
GUICtrlSetData($Progress1, 94)
sleep(40)
GUICtrlSetData($Progress1, 95)
sleep(40)
GUICtrlSetData($Progress1, 96)
sleep(40)
GUICtrlSetData($Progress1, 97)
sleep(40)
GUICtrlSetData($Progress1, 98)
sleep(40)
GUICtrlSetData($Progress1, 99)
sleep(40)
GUICtrlSetData($Progress1, 100)

MsgBox(0,"test", "test worked")


Exit

:D

Link to comment
Share on other sites

  • Developers

Ok I post you all the script:

Just defining the _InetSmtpMailCom() Func doesn't means it is performed.

To perform the function you need to call it in your code by:

_InetSmtpMailCom($s_SmtpServer, ..........)

Have a look at the examples posted for this Function.

Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Moderators

Instead of that long 200 line code there for:

GUICtrlSetData($Progress1, 2)
sleep(40)
;etc...

Loops are your friend :D

For $iCount = 2 To 100
    GUICtrlSetData($Progress1, $iCount)
    Sleep(40)
Next

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Thx that works :D

But have new error now :s

when I load the script I have:

Line 45 (....):

$S_Files2arrach[$x]= _PathFull ($S_Files2Arrach[$x])

$S_Files2arrach[$x] = ^ ERROR

Error: Unknow function name.

How can I fix it?
Link to comment
Share on other sites

  • Developers

Thx that works :D

But have new error now :s

when I load the script I have:

How can I fix it?

_PathFull

--------------------------------------------------------------------------------

Creates a path based on the relative path you provide. The newly created absolute path is returned

#include <File.au3>

_PathFull($szRelPath)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...