Jump to content

says func has no matching endfunc but it do....


join
 Share

Recommended Posts

Are you making a email sender? If you are, take a look at my sig. Here the source:

#cs ----------------------------------------------------------------------------
    
    AutoIt Version: 3.2.12.1
    Author:         myName
    
    Script Function:
    Template AutoIt script.
    
#ce ----------------------------------------------------------------------------

#include <GUIConstants.au3>
#include <File.au3>



$Form2 = GUICreate("Email Sender 1.0", 465, 328, 189, 122)
$Label_Username = GUICtrlCreateLabel("Gmail Username", 320, 64, 81, 17)
$GmailUser = GUICtrlCreateInput("", 320, 80, 121, 21)
$Label_Pasword = GUICtrlCreateLabel("Gmail Password", 320, 104, 79, 17)
$GmailPass = GUICtrlCreateInput("", 320, 120, 121, 21)
$Label_to = GUICtrlCreateLabel("To:", 8, 32, 24, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$GmailToAdress = GUICtrlCreateInput("", 56, 32, 177, 21)
$Label_Subject = GUICtrlCreateLabel("Subject:", 0, 56, 52, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$GmailSubject = GUICtrlCreateInput("", 56, 56, 177, 21)
$Label_body = GUICtrlCreateLabel("Body", 16, 88, 28, 17)
$GmailBody = GUICtrlCreateEdit("", 16, 104, 273, 185)
$Group_account = GUICtrlCreateGroup("Account info", 312, 48, 145, 129)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$GmailSend = GUICtrlCreateButton("Send", 336, 200, 75, 25, 0)
$Cancel = GUICtrlCreateButton("Cancel", 336, 240, 75, 25, 0)
$MenuItem1 = GUICtrlCreateMenu("&File")
$MenuItem_about = GUICtrlCreateMenuItem("About", $MenuItem1)
$MenuItem_exit = GUICtrlCreateMenuItem("Exit", $MenuItem1)

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###



While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Cancel
            Exit
        Case $MenuItem_about
            MsgBox(64, "Email Sender 1.0", "This Email Sender is made by Farhan as a efficient and convenient application to send emails." & @CRLF & @CRLF & "(c) Copyright 2008. All Rights Reseved.")


        Case $MenuItem_exit
            Exit
        Case $GmailSend
            $SmtpServer = "smtp.gmail.com"
            $FromName = "Mail"
            $FromAddress = "STARTTLS"
            $ToAddress = GUICtrlRead($GmailToAdress)
            $Subject = GUICtrlRead($GmailSubject)
            $Body = GUICtrlRead($GmailBody)
            $AttachFiles = ""
            $CcAddress = ""
            $BccAddress = ""
            $Importance = "Normal"
            $Username = GUICtrlRead($GmailUser)
            $Password = GUICtrlRead($GmailPass)
            $IPPort = 25
            $ssl = 0
            $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
                MsgBox(0, "Error sending message", "Error code:" & @error & "  Description:" & $rc)
            Else
                MsgBox(64, "Success", "Your email is successfully sent")
            EndIf
            ;
            ; The UDF
            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(62) : $S_Files2Attach = ' & $S_Files2Attach & @LF & '>Error code: ' & @error & @LF) ;### Debug Console
                        If FileExists($S_Files2Attach[$x]) Then
                            $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 ""
                        $objEmail.Fields.Item("urn:schemas:mailheader:Importance") = "H"
                    Case ""
                        $objEmail.Fields.Item("urn:schemas:mailheader:Importance") = "N"
                    Case ""
                        $objEmail.Fields.Item("urn:schemas:mailheader:Importance") = "L"
                EndSwitch
                $objEmail.Fields.Update
                ; Sent the Message
                $objEmail.Send
                If @error Then
                    SetError(2)
                    Return $oMyRet[1]
                EndIf
                $objEmail = ""
            EndFunc   ;==>_INetSmtpMailCom

            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



    EndSwitch

WEnd
System task ---> My first GUICalculator v1.0 ---> My version of the calculatorNetZilla 1.0 --> Web browserEmail Sender --> You can Send emails with this without opening a web browser
Link to comment
Share on other sites

acctualy im trying to make a test program that when you press the button, it will take a screenshot (fixed) and then mail it to me, but the mail script is a "func" and you can´t have a fun in another func (CRAP!) thats what im trying to fix... here is my script anyway.

#Region;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_LegalCopyright=no copyright, free distrubate!
#EndRegion;**** Directives created by AutoIt3Wrapper_GUI ****
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; this generator was made by join ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

#include <ScreenCapture.au3>
#Include <file.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=C:\Users\haamster\Desktop\gamecard generator\gamecard generator.kxf
$FORM = GUICreate("GENERATOR", 500, 261, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "FORMClose")
$first = GUICtrlCreateLabel("moahaha", 216, 40, 51, 17)
$gamecard_nr1 = GUICtrlCreateInput("", 56, 64, 81, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
GUICtrlSetTip(-1, "put in something here")
$Input1 = GUICtrlCreateInput("", 152, 64, 81, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER) )
$Input2 = GUICtrlCreateInput("", 256, 64, 81, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER) )
$Input3 = GUICtrlCreateInput("", 360, 64, 81, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER) )
$Label1 = GUICtrlCreateLabel("__", 136, 64, 16, 17)
$Label2 = GUICtrlCreateLabel("__", 240, 64, 16, 17)
$Label3 = GUICtrlCreateLabel("__", 344, 64, 16, 17)
$Label4 = GUICtrlCreateLabel("generated code", 200, 104, 79, 17)
$gamecard_nr2 = GUICtrlCreateInput("", 56, 136, 81, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY,$ES_NUMBER))
GUICtrlSetTip(-1, "put in some funny shit here")
$Input5 = GUICtrlCreateInput("", 152, 136, 81, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY,$ES_NUMBER))
GUICtrlSetTip(-1, "put in stuff here")
$Input6 = GUICtrlCreateInput("", 248, 136, 81, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY,$ES_NUMBER))
GUICtrlSetTip(-1, "put in ... here")
$Input7 = GUICtrlCreateInput("", 344, 136, 81, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY,$ES_NUMBER))
GUICtrlSetTip(-1, "put in...whatever... here")
$Label5 = GUICtrlCreateLabel("__", 136, 136, 16, 17)
$Label6 = GUICtrlCreateLabel("__", 232, 136, 16, 17)
$Label7 = GUICtrlCreateLabel("__", 328, 136, 16, 17)
$generate = GUICtrlCreateButton("generate", 200, 176, 113, 33, 0)
GUICtrlSetOnEvent(-1, "generateClick")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


While 1
    Sleep(100)
WEnd

Func FORMClose()
Exit
EndFunc

Func generateClick()
_ScreenCapture_Capture(@MyDocumentsDir & "\test.jpg")

Global $quality = 50
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")

$s_SmtpServer = "smtp.gmail.com"; address for the smtp-server to use - REQUIRED
$s_FromName = "******"; name from who the email was sent
$s_FromAddress = "**********@gmail.com"; address from where the mail should come
$s_ToAddress = "**************@hotmail.com"; destination address of the email - REQUIRED
$s_Subject = "******"; subject from the email - can be anything you want it to be
$as_Body = "text here"; the messagebody from the mail - can be left blank but then you get a blank mail
$s_AttachFiles = "@MyDocumentsDir & \test.jpg"; the file you want to attach- leave blank if not needed
$s_CcAddress = ""; address for cc - leave blank if not needed
$s_BccAddress = ""; address for bcc - leave blank if not needed
$s_Username = "********"; username for the account used from where the mail gets sent - Optional (Needed for eg GMail)
$s_Password = "*************"; password for the account used from where the mail gets sent - Optional (Needed for eg GMail)
;$IPPort = 25; port used for sending the mail
;$ssl = 0; enables/disables secure socket layer sending - put to 1 if using httpS
$IPPort=465; GMAIL port used for sending the mail
$ssl=1; GMAILenables/disables secure socket layer sending - put to 1 if using httpS

;##################################
; Email Script
;##################################
Global $oMyRet[2]
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
$rc = _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, $s_AttachFiles, $s_CcAddress, $s_BccAddress, $s_Username, $s_Password, $IPPort, $ssl)
If @error Then
MsgBox(0, "Error sending message", "Error code:" & @error & " Rc:" & $rc)
EndIf
;

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.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])
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

; 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
EndIf
EndFunc
EndFunc

i been editing a little but it´s still the same "code"

Link to comment
Share on other sites

You aren't listening. You have a function declared inside the other function. Change it to this, like you were told to before.

#Region;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_LegalCopyright=no copyright, free distrubate!
#EndRegion;**** Directives created by AutoIt3Wrapper_GUI ****
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; this generator was made by join ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

#include <ScreenCapture.au3>
#Include <file.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=C:\Users\haamster\Desktop\gamecard generator\gamecard generator.kxf
$FORM = GUICreate("GENERATOR", 500, 261, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "FORMClose")
$first = GUICtrlCreateLabel("moahaha", 216, 40, 51, 17)
$gamecard_nr1 = GUICtrlCreateInput("", 56, 64, 81, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
GUICtrlSetTip(-1, "put in something here")
$Input1 = GUICtrlCreateInput("", 152, 64, 81, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER) )
$Input2 = GUICtrlCreateInput("", 256, 64, 81, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER) )
$Input3 = GUICtrlCreateInput("", 360, 64, 81, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER) )
$Label1 = GUICtrlCreateLabel("__", 136, 64, 16, 17)
$Label2 = GUICtrlCreateLabel("__", 240, 64, 16, 17)
$Label3 = GUICtrlCreateLabel("__", 344, 64, 16, 17)
$Label4 = GUICtrlCreateLabel("generated code", 200, 104, 79, 17)
$gamecard_nr2 = GUICtrlCreateInput("", 56, 136, 81, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY,$ES_NUMBER))
GUICtrlSetTip(-1, "put in some funny shit here")
$Input5 = GUICtrlCreateInput("", 152, 136, 81, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY,$ES_NUMBER))
GUICtrlSetTip(-1, "put in stuff here")
$Input6 = GUICtrlCreateInput("", 248, 136, 81, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY,$ES_NUMBER))
GUICtrlSetTip(-1, "put in ... here")
$Input7 = GUICtrlCreateInput("", 344, 136, 81, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY,$ES_NUMBER))
GUICtrlSetTip(-1, "put in...whatever... here")
$Label5 = GUICtrlCreateLabel("__", 136, 136, 16, 17)
$Label6 = GUICtrlCreateLabel("__", 232, 136, 16, 17)
$Label7 = GUICtrlCreateLabel("__", 328, 136, 16, 17)
$generate = GUICtrlCreateButton("generate", 200, 176, 113, 33, 0)
GUICtrlSetOnEvent(-1, "generateClick")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


While 1
    Sleep(100)
WEnd

Func FORMClose()
Exit
EndFunc

Func generateClick()
_ScreenCapture_Capture(@MyDocumentsDir & "\test.jpg")

Global $quality = 50
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")

$s_SmtpServer = "smtp.gmail.com"; address for the smtp-server to use - REQUIRED
$s_FromName = "******"; name from who the email was sent
$s_FromAddress = "**********@gmail.com"; address from where the mail should come
$s_ToAddress = "**************@hotmail.com"; destination address of the email - REQUIRED
$s_Subject = "******"; subject from the email - can be anything you want it to be
$as_Body = "text here"; the messagebody from the mail - can be left blank but then you get a blank mail
$s_AttachFiles = "@MyDocumentsDir & \test.jpg"; the file you want to attach- leave blank if not needed
$s_CcAddress = ""; address for cc - leave blank if not needed
$s_BccAddress = ""; address for bcc - leave blank if not needed
$s_Username = "********"; username for the account used from where the mail gets sent - Optional (Needed for eg GMail)
$s_Password = "*************"; password for the account used from where the mail gets sent - Optional (Needed for eg GMail)
;$IPPort = 25; port used for sending the mail
;$ssl = 0; enables/disables secure socket layer sending - put to 1 if using httpS
$IPPort=465; GMAIL port used for sending the mail
$ssl=1; GMAILenables/disables secure socket layer sending - put to 1 if using httpS

;##################################
; Email Script
;##################################
Global $oMyRet[2]
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
$rc = _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, $s_AttachFiles, $s_CcAddress, $s_BccAddress, $s_Username, $s_Password, $IPPort, $ssl)
If @error Then
MsgBox(0, "Error sending message", "Error code:" & @error & " Rc:" & $rc)
EndIf
EndFunc

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.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])
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

; 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
EndIf
EndFunc
Link to comment
Share on other sites

acctualy im trying to make a test program that when you press the button, it will take a screenshot (fixed) and then mail it to me, but the mail script is a "func" and you can´t have a fun in another func (CRAP!) thats what im trying to fix... here is my script anyway.

#Region;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_LegalCopyright=no copyright, free distrubate!
#EndRegion;**** Directives created by AutoIt3Wrapper_GUI ****
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; this generator was made by join;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

#include <ScreenCapture.au3>
#Include <file.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=C:\Users\haamster\Desktop\gamecard generator\gamecard generator.kxf
$FORM = GUICreate("GENERATOR", 500, 261, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "FORMClose")
$first = GUICtrlCreateLabel("moahaha", 216, 40, 51, 17)
$gamecard_nr1 = GUICtrlCreateInput("", 56, 64, 81, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
GUICtrlSetTip(-1, "put in something here")
$Input1 = GUICtrlCreateInput("", 152, 64, 81, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER) )
$Input2 = GUICtrlCreateInput("", 256, 64, 81, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER) )
$Input3 = GUICtrlCreateInput("", 360, 64, 81, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER) )
$Label1 = GUICtrlCreateLabel("__", 136, 64, 16, 17)
$Label2 = GUICtrlCreateLabel("__", 240, 64, 16, 17)
$Label3 = GUICtrlCreateLabel("__", 344, 64, 16, 17)
$Label4 = GUICtrlCreateLabel("generated code", 200, 104, 79, 17)
$gamecard_nr2 = GUICtrlCreateInput("", 56, 136, 81, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY,$ES_NUMBER))
GUICtrlSetTip(-1, "put in some funny shit here")
$Input5 = GUICtrlCreateInput("", 152, 136, 81, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY,$ES_NUMBER))
GUICtrlSetTip(-1, "put in stuff here")
$Input6 = GUICtrlCreateInput("", 248, 136, 81, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY,$ES_NUMBER))
GUICtrlSetTip(-1, "put in ... here")
$Input7 = GUICtrlCreateInput("", 344, 136, 81, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY,$ES_NUMBER))
GUICtrlSetTip(-1, "put in...whatever... here")
$Label5 = GUICtrlCreateLabel("__", 136, 136, 16, 17)
$Label6 = GUICtrlCreateLabel("__", 232, 136, 16, 17)
$Label7 = GUICtrlCreateLabel("__", 328, 136, 16, 17)
$generate = GUICtrlCreateButton("generate", 200, 176, 113, 33, 0)
GUICtrlSetOnEvent(-1, "generateClick")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


While 1
    Sleep(100)
WEnd

Func FORMClose()
Exit
EndFunc

Func generateClick()
_ScreenCapture_Capture(@MyDocumentsDir & "\test.jpg")

Global $quality = 50
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")

$s_SmtpServer = "smtp.gmail.com"; address for the smtp-server to use - REQUIRED
$s_FromName = "******"; name from who the email was sent
$s_FromAddress = "**********@gmail.com"; address from where the mail should come
$s_ToAddress = "**************@hotmail.com"; destination address of the email - REQUIRED
$s_Subject = "******"; subject from the email - can be anything you want it to be
$as_Body = "text here"; the messagebody from the mail - can be left blank but then you get a blank mail
$s_AttachFiles = "@MyDocumentsDir & \test.jpg"; the file you want to attach- leave blank if not needed
$s_CcAddress = ""; address for cc - leave blank if not needed
$s_BccAddress = ""; address for bcc - leave blank if not needed
$s_Username = "********"; username for the account used from where the mail gets sent - Optional (Needed for eg GMail)
$s_Password = "*************"; password for the account used from where the mail gets sent - Optional (Needed for eg GMail)
;$IPPort = 25; port used for sending the mail
;$ssl = 0; enables/disables secure socket layer sending - put to 1 if using httpS
$IPPort=465; GMAIL port used for sending the mail
$ssl=1; GMAILenables/disables secure socket layer sending - put to 1 if using httpS

;##################################
; Email Script
;##################################
Global $oMyRet[2]
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
$rc = _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, $s_AttachFiles, $s_CcAddress, $s_BccAddress, $s_Username, $s_Password, $IPPort, $ssl)
If @error Then
MsgBox(0, "Error sending message", "Error code:" & @error & " Rc:" & $rc)
EndIf
;

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.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])
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

; 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
EndIf
EndFunc
EndFunc

i been editing a little but it´s still the same "code"

Your functions are really messed up. The code should look like this...

#Region;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_LegalCopyright=no copyright, free distrubate!
#EndRegion;**** Directives created by AutoIt3Wrapper_GUI ****
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; this generator was made by join;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

#include <ScreenCapture.au3>
#include <file.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=C:\Users\haamster\Desktop\gamecard generator\gamecard generator.kxf
$FORM = GUICreate("GENERATOR", 500, 261, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "FORMClose")
$first = GUICtrlCreateLabel("moahaha", 216, 40, 51, 17)
$gamecard_nr1 = GUICtrlCreateInput("", 56, 64, 81, 21, BitOR($ES_AUTOHSCROLL, $ES_NUMBER))
GUICtrlSetTip(-1, "put in something here")
$Input1 = GUICtrlCreateInput("", 152, 64, 81, 21, BitOR($ES_AUTOHSCROLL, $ES_NUMBER))
$Input2 = GUICtrlCreateInput("", 256, 64, 81, 21, BitOR($ES_AUTOHSCROLL, $ES_NUMBER))
$Input3 = GUICtrlCreateInput("", 360, 64, 81, 21, BitOR($ES_AUTOHSCROLL, $ES_NUMBER))
$Label1 = GUICtrlCreateLabel("__", 136, 64, 16, 17)
$Label2 = GUICtrlCreateLabel("__", 240, 64, 16, 17)
$Label3 = GUICtrlCreateLabel("__", 344, 64, 16, 17)
$Label4 = GUICtrlCreateLabel("generated code", 200, 104, 79, 17)
$gamecard_nr2 = GUICtrlCreateInput("", 56, 136, 81, 21, BitOR($ES_AUTOHSCROLL, $ES_READONLY, $ES_NUMBER))
GUICtrlSetTip(-1, "put in some funny shit here")
$Input5 = GUICtrlCreateInput("", 152, 136, 81, 21, BitOR($ES_AUTOHSCROLL, $ES_READONLY, $ES_NUMBER))
GUICtrlSetTip(-1, "put in stuff here")
$Input6 = GUICtrlCreateInput("", 248, 136, 81, 21, BitOR($ES_AUTOHSCROLL, $ES_READONLY, $ES_NUMBER))
GUICtrlSetTip(-1, "put in ... here")
$Input7 = GUICtrlCreateInput("", 344, 136, 81, 21, BitOR($ES_AUTOHSCROLL, $ES_READONLY, $ES_NUMBER))
GUICtrlSetTip(-1, "put in...whatever... here")
$Label5 = GUICtrlCreateLabel("__", 136, 136, 16, 17)
$Label6 = GUICtrlCreateLabel("__", 232, 136, 16, 17)
$Label7 = GUICtrlCreateLabel("__", 328, 136, 16, 17)
$generate = GUICtrlCreateButton("generate", 200, 176, 113, 33, 0)
GUICtrlSetOnEvent(-1, "generateClick")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


While 1
    Sleep(100)
WEnd

Func FORMClose()
    Exit
EndFunc  ;==>FORMClose

Func generateClick()
    _ScreenCapture_Capture(@MyDocumentsDir & "\test.jpg")

    Global $quality = 50
    Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")

    $s_SmtpServer = "smtp.gmail.com"; address for the smtp-server to use - REQUIRED
    $s_FromName = "******"; name from who the email was sent
    $s_FromAddress = "**********@gmail.com"; address from where the mail should come
    $s_ToAddress = "**************@hotmail.com"; destination address of the email - REQUIRED
    $s_Subject = "******"; subject from the email - can be anything you want it to be
    $as_Body = "text here"; the messagebody from the mail - can be left blank but then you get a blank mail
    $s_AttachFiles = "@MyDocumentsDir & \test.jpg"; the file you want to attach- leave blank if not needed
    $s_CcAddress = ""; address for cc - leave blank if not needed
    $s_BccAddress = ""; address for bcc - leave blank if not needed
    $s_Username = "********"; username for the account used from where the mail gets sent - Optional (Needed for eg GMail)
    $s_Password = "*************"; password for the account used from where the mail gets sent - Optional (Needed for eg GMail)
;$IPPort = 25; port used for sending the mail
;$ssl = 0; enables/disables secure socket layer sending - put to 1 if using httpS
    $IPPort = 465; GMAIL port used for sending the mail
    $ssl = 1; GMAILenables/disables secure socket layer sending - put to 1 if using httpS

;##################################
; Email Script
;##################################
    Global $oMyRet[2]
    Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
    $rc = _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, $s_AttachFiles, $s_CcAddress, $s_BccAddress, $s_Username, $s_Password, $IPPort, $ssl)
    If @error Then
        MsgBox(0, "Error sending message", "Error code:" & @error & " Rc:" & $rc)
    EndIf
;
EndFunc  ;==>generateClick
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.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])
            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
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...