Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

_INetSmtpMailCom problem - $objEmail.Send fails

$
0
0
I'm having some problem with the UDF _INetSmtpMailCom
When I run the script, there's no problem, it works fine. But when I build the executable and run it, it throws an error: "The requested action with this object has failed."
Here's the script I've tried on
[ autoit ]         
#include "C:\Program Files\AutoIt3\User Include\_INetSmtpMailCom.au3" mail_me() Func mail_me () Local $srand = Random(1000, 20000, 1) RunWait(@ScriptDir & "/7za.exe a archive" & $srand & ".7z *.jpg", @ScriptDir, @SW_HIDE) Local $SmtpServer = "smtp.mail.yahoo.com" Local $FromName = "baddy" Local $FromAddress = "user1@yahoo.com" Local $ToAddress = "user2@gmail.com" Local $body = "test" Local $Subject = "test attchment" Local $attchmnts = "" Local $BccAddress = "" Local $CcAddress = "" Local $imp = "Normal" Local $usernm = "user1@yahoo.com" Local $passw = "pahahaha" Local $port = 465 Local $ssl = 1 Local $search = FileFindFirstFile("*.7z") While 1 $temp = FileFindNextFile($search) & ";" If @error Then ExitLoop MsgBox(64, "", $attchmnts) $attchmnts &= $temp WEnd SetError(0) $attchmnts = StringTrimRight($attchmnts, 1) MsgBox(64, "", $attchmnts) _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $body, $attchmnts, $CcAddress, $BccAddress, $imp, $usernm, $passw, Number($port), 1) If @error Then MsgBox(0, "", "mail error") EndIf FileClose($search) ;#cs EndFunc

The below one, while running the script, gives the same error with a little more information. The action that failed is $objEmail.Send.
Now I dont know much about COM objects and stuffs. Hope somebody can clarify whats happening here.
[ autoit ]         
#include "C:\Program Files\AutoIt3\User Include\_INetSmtpMailCom.au3" ;#include <_INetSmtpMailCom.au3> #Include <File.au3> #Include <GuiEdit.au3> #include <GuiConstantsEx.au3> #include <UpdownConstants.au3> #include <WindowsConstants.au3> #Region Creating GUI GUICreate ( "Mailer 0.81", 415, 495 ) ;415,295 GUICtrlCreateLabel ( "SMTP Server*", 15, 18 ) GUICtrlCreateLabel ( "Name sender", 15, 18+25 ) GUICtrlCreateLabel ( "E-mail sender", 15, 18+25*2 ) GUICtrlCreateLabel ( "E-mail receiver*", 15, 18+25*3 ) GUICtrlCreateLabel ( "Subject", 15, 18+25*4 ) GUICtrlCreateLabel ( "Your message:", 230, 17 ) $Q1 = GUICtrlCreateLabel ( "?", 207, 18 ) $Q2 = GUICtrlCreateLabel ( "?", 207, 18+25 ) $Q3 = GUICtrlCreateLabel ( "?", 207, 18+25*2 ) $Q4 = GUICtrlCreateLabel ( "?", 207, 18+25*3 ) $Q5 = GUICtrlCreateLabel ( "?", 207, 18+25*4 ) $Q6 = GUICtrlCreateLabel ( "?", 372, 17 ) $Q7 = GUICtrlCreateLabel ( "?", 193, 167 ) $Q8 = GUICtrlCreateLabel ( "?", 371, 167 ) $ISMTP = GUICtrlCreateInput ( "", 100, 15, 100, 20, $ES_READONLY ) $INameSender = GUICtrlCreateInput ( "", 100, 15+25, 80, 20 ) $IEmailSender = GUICtrlCreateInput ( "", 100, 15+25*2, 80, 20 ) $IEmailReceiver = GUICtrlCreateInput ( "", 100, 15+25*3, 100, 20 ) $ISubject = GUICtrlCreateInput ( "", 100, 15+25*4, 80, 20 ) $IMessage = GUICtrlCreateEdit ( "", 230, 36, 170, 99, $ES_WANTRETURN + $ES_AUTOVSCROLL + $WS_VSCROLL ) GUICtrlCreateGroup ( "Account information", 15, 145, 380, 49 ) GUICtrlCreateLabel ( "Username*", 30, 167 ) GUICtrlCreateLabel ( "Password*", 210, 167 ) $AUsername = GUICtrlCreateInput ( "", 87, 164, 100 ) $APassword = GUICtrlCreateInput ( "", 265, 164, 100 ) GUICtrlCreateGroup ( "Priority", 15, 200, 200, 49 ) $PriorLow = GUICtrlCreateRadio ( "Low", 30, 217 ) $PriorNormal = GUICtrlCreateRadio ( "Normal", 88, 217 ) $PriorHigh = GUICtrlCreateRadio ( "High", 156, 217 ) $InfoLabel = GUICtrlCreateLabel ( "Fill in the required information and press send.", 15, 265, 300, 20, $ES_CENTER ) $Send = GUICtrlCreateButton ( "Send", 315, 260, 80, 25 ) $CNameSender = GUICtrlCreateCheckBox ( "", 185, 44, 20, 12 ) $CEmailSender = GUICtrlCreateCheckBox ( "", 185, 69, 20, 12 ) $CSubject = GUICtrlCreateCheckBox ( "", 185, 119, 20, 12 ) $CMessage = GUICtrlCreateCheckBox ( "", 385, 18, 20, 12 ) $FromNameDummy = GUICtrlCreateLabel ( "FromNameDummy", 10, 300 ) $FromAddressDummy = GUICtrlCreateLabel ( "FromAddressDummy", 200, 300 ) $SubjectDummy = GUICtrlCreateLabel ( "SubjectDummy", 10, 320 ) $MessageDummy = GUICtrlCreateLabel ( "MessageDummy", 10, 340, 395, 200 ) #EndRegion ;Fills GUICtrlSetData ( $ISMTP, "smtp.gmail.com" ) GUICtrlSetData ( $INameSender, "TestAccount" ) GUICtrlSetData ( $IEmailSender, "TestAccount@Test.nl" ) GUICtrlSetData ( $IEmailReceiver, "supercasje@gmail.com" ) GUICtrlSetData ( $ISubject, "The testsubject" ) GUICtrlSetData ( $IMessage, "Testing message," & @CRLF & @CRLF & "Made by Rawox" & @CRLF & "lol" ) GUICtrlSetData ( $AUsername, "***" ) GUICtrlSetData ( $APassword, "***" ) #Region Changes GUICtrlSetTip ( $Q1, "The SMTP Server is required to send emails through."& @CRLF & "Only Gmail (smtp.gmail.com) is working.", "SMTP Server (Required)", 1, 1 ) GUICtrlSetTip ( $Q2, "Use your own name or some else's to keep you unkown." & @CRLF & "Check the box to use random names.", "Name sender", 1, 1 ) GUICtrlSetTip ( $Q3, "Use your own email adrress or someone else's to keep you unknown." & @CRLF & "Check the box to use random email addresses.", "E-mail sender", 1, 1 ) GUICtrlSetTip ( $Q4, "The email address of the receiver, the emails will be send" & @CRLF & "to this email address so make sure it is correct", "E-mail receiver (Required)", 1, 1 ) GUICtrlSetTip ( $Q5, "The subject of the messages you are sending." & @CRLF & "Check the box to use random subjects.", "Subject", 1, 1 ) GUICtrlSetTip ( $Q6, "The body of the messages you are sending." & @CRLF & "Check the box to use random messages.", "Your message", 1, 1 ) GUICtrlSetTip ( $Q7, "The username of an existing email account." & @CRLF & "e.g. John, no full e-mail addresses like Jon@provider.net", "Username", 1, 1 ) GUICtrlSetTip ( $Q8, "The password that is used for the chosen email address." & @CRLF & "Your password will not be abused.", "Password", 1, 1 ) GUICtrlSetColor ( $Q1, 0xb0b0b0 ) GUICtrlSetColor ( $Q2, 0xb0b0b0 ) GUICtrlSetColor ( $Q3, 0xb0b0b0 ) GUICtrlSetColor ( $Q4, 0xb0b0b0 ) GUICtrlSetColor ( $Q5, 0xb0b0b0 ) GUICtrlSetColor ( $Q6, 0xb0b0b0 ) GUICtrlSetColor ( $Q7, 0xb0b0b0 ) GUICtrlSetColor ( $Q8, 0xb0b0b0 ) GUICtrlSetState ( $PriorNormal, $GUI_CHECKED ) GUISetState ( @SW_SHOW ) #EndRegion While 1 Switch GUIGetMsg() Case $Send      $SmtpServer = GUICtrlRead ( $ISMTP )                        ; address for the smtp-server to use - REQUIRED\      If GUICtrlRead ( $CNameSender ) = $GUI_CHECKED Then             ; name from who the email was sent          $Length = Random ( 5, 30, 1 )          GUICtrlSetData ( $FromNameDummy, CreateRandomString ( $Length ) )          $FromName = GUICtrlRead ( $FromNameDummy )      Else          $FromName = GUICtrlRead ( $INameSender )      EndIf      If GUICtrlRead ( $CEmailSender ) = $GUI_CHECKED Then        ; address from where the mail should come          $Length = Random ( 5, 30, 1 )          GUICtrlSetData ( $FromAddressDummy, CreateRandomString ( $Length ) )          $FromAddress = GUICtrlRead ( $FromAddressDummy )      Else          $FromAddress = GUICtrlRead ( $INameSender )      EndIf      $ToAddress = GUICtrlRead ( $IEmailReceiver )                ; destination address of the email - REQUIRED      If GUICtrlRead ( $CSubject ) = $GUI_CHECKED Then            ; subject from the email - can be anything you want it to be          $Length = Random ( 5, 30, 1 )          GUICtrlSetData ( $SubjectDummy, CreateRandomString ( $Length ) )          $Subject = GUICtrlRead ( $SubjectDummy )      Else          $Subject = GUICtrlRead ( $INameSender )      EndIf                                           If GUICtrlRead ( $CMessage ) = $GUI_CHECKED Then            ; the messagebody from the mail - can be left blank but then you get a blank mail          $Length = Random ( 40, 320, 1 )          GUICtrlSetData ( $MessageDummy, CreateRandomString ( $Length / 15 ) & @CRLF & @CRLF & _                                          CreateRandomString ( $Length / 1.5 ) & @CRLF & @CRLF & _                                          CreateRandomString ( $Length * 2 ) & @CRLF & @CRLF & _                                          CreateRandomString ( $Length / 10 ) & @CRLF & _                                          CreateRandomString ( $Length / 20 ) & @CRLF )          $Body = GUICtrlRead ( $MessageDummy )      Else          $Body = GUICtrlRead ( $INameSender )      EndIf                           $AttachFiles = ""                                           ; the file you want to attach- leave blank if not needed      $CcAddress = ""                                                 ; address for cc - leave blank if not needed      $BccAddress = ""                                            ; address for bcc - leave blank if not needed      If GUICtrlRead ( $PriorLow ) = $GUI_CHECKED Then            ; Send message priority: "High", "Normal", "Low"          $Importance = "Low"      ElseIf GUICtrlRead ( $PriorHigh ) = $GUI_CHECKED Then          $Importance = "High"      Else          $Importance = "Normal"      EndIf      $Username = GUICtrlRead ( $AUsername )                      ; username for the account used from where the mail gets sent - REQUIRED      $Password = GUICtrlRead ( $APassword )                      ; password for the account used from where the mail gets sent - REQUIRED      $IPPort = 465                                               ; GMAIL port used for sending the mail      $ssl = 1                                                    ; enables/disables secure socket layer sending - put to 1 if using httpS      ;~ $IPPort=25                                               ; NOT GMAIL port used for sending the mail      ;~ $ssl=0                                                   ; enables/disables secure socket layer sending - put to 1 if using httpS          _INetSmtpMailCom ( $SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl )     Case $CNameSender      If GUICtrlRead ( $CNameSender ) = $GUI_CHECKED Then          GUICtrlSetState ( $INameSender+1, $GUI_FOCUS )          GUICtrlSetData ( $INameSender, "Random" )          GUICtrlSetState ( $INameSender, $GUI_DISABLE )      Else          GUICtrlSetData ( $INameSender, "" )          GUICtrlSetState ( $INameSender, $GUI_ENABLE )          GUICtrlSetState ( $INameSender, $GUI_FOCUS )      EndIf Case $CEmailSender      If GUICtrlRead ( $CEmailSender ) = $GUI_CHECKED Then          GUICtrlSetState ( $IEmailSender+1, $GUI_FOCUS )          GUICtrlSetData ( $IEmailSender, "Random" )          GUICtrlSetState ( $IEmailSender, $GUI_DISABLE )      Else          GUICtrlSetData ( $IEmailSender, "" )          GUICtrlSetState ( $IEmailSender, $GUI_ENABLE )          GUICtrlSetState ( $IEmailSender, $GUI_FOCUS )      EndIf Case $CSubject      If GUICtrlRead ( $CSubject ) = $GUI_CHECKED Then          GUICtrlSetState ( $ISubject+1, $GUI_FOCUS )          GUICtrlSetData ( $ISubject, "Random" )          GUICtrlSetState ( $ISubject, $GUI_DISABLE )      Else          GUICtrlSetData ( $ISubject, "" )          GUICtrlSetState ( $ISubject, $GUI_ENABLE )          GUICtrlSetState ( $ISubject, $GUI_FOCUS )      EndIf Case $CMessage      If GUICtrlRead ( $CMessage ) = $GUI_CHECKED Then          GUICtrlSetState ( $IMessage+1, $GUI_FOCUS )          GUICtrlSetData ( $IMessage, "Random" )          GUICtrlSetState ( $IMessage, $GUI_DISABLE )      Else          GUICtrlSetData ( $IMessage, "" )          GUICtrlSetState ( $IMessage, $GUI_ENABLE )          GUICtrlSetState ( $IMessage, $GUI_FOCUS )      EndIf Case $GUI_EVENT_CLOSE      Exit EndSwitch WEnd Func CreateRandomString ( $Length ) $RandomSN = Random ( 3, 14, 1 )                          ; Spaces $j = 0                                                   ; Spaces Local $Word = ""                                         ; Base For $i = 1 to $Length                                    ; Base      $Word &= Chr ( Random ( 50, 127, 1 ) )              ; Base      If $j = $RandomSN Then                              ; Spaces          $Word &= " "                                    ; Spaces          $RandomSN = Random ( 3, 14,1 )                  ; Spaces          $j = 0                                          ; Spaces      Else                                                ; Spaces          $j += 1                                             ; Spaces      EndIf                                               ; Spaces Next                                                     ; Base $FromName = $Word                                        ; Base Return $FromName                                         ; Base EndFunc

Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>