Sign in to follow this  
Followers 0
Rawox

_INetSmtpMailCom.au3 Error

24 posts in this topic

Hi Guys,

I tried to use the _INetSmtpMailCom UDF but I get this error when I try to send the message...

C:\Program Files\AutoIt3\Include\_INetSmtpMailCom.au3 (55) : ==> The requested action with this object has failed.:
$objEmail.Send
$objEmail.Send^ ERROR

Dummy vars, username and passwords are left empty because I use my l brothers to check the script.

GUICtrlSetData ( $ISMTP, "smtp.live.com" )
GUICtrlSetData ( $INameSender, "TestAccount" )
GUICtrlSetData ( $IEmailSender, "TestAccount@Test.nl" )
GUICtrlSetData ( $IEmailReceiver, "supercasje@hotmail.com" )
GUICtrlSetData ( $ISubject, "The testsubject" )
GUICtrlSetData ( $IMessage, "Testing message," & @CRLF & @CRLF & "Made by Rawox" & @CRLF & "lol" )
GUICtrlSetData ( $AUsername, "****" )
GUICtrlSetData ( $APassword, "****" )

Setting variables

$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 = 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                               ; GMAIL 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 )

I don't know, do you??

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Also use the ComErrorHandler as shown in the Examples Thread on this UDF. It tell you probably more about your issue.

Edit: Are you sure you can send an Email via this SMTP server with that source Email address?

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

No I am not sure, how can I find out if this is possible?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

No I am not sure, how can I find out if this is possible?

Test it with Outlook Express, but I am pretty sure this is impossible. This is a standard anti Spam/Relaying measure)

You will have to find a SMTP server of which you are sure you are allowed to send mail to from your current location. Gmail will work from any internet connection.

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

So I can use Gmail in my script?

Or do I need to configure an Outlook account?

Share this post


Link to post
Share on other sites

So I can use Gmail in my script?

Or do I need to configure an Outlook account?

Yeap: GMail works... Its described in the thread I posted this UDF and documented in the source.

No need to configure an account in outlook as this UDF runs stand-alone, but you could do it for testing purposes.

Veel plezier,

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Hi Jos,

I still don't get it. I do now use smtp.gmail.com. I send the message from a Gmail account to another Gmail account but I get the same error:

C:\Program Files\AutoIt3\Include\_INetSmtpMailCom.au3 (55) : ==> The requested action with this object has failed.:
$objEmail.Send
$objEmail.Send^ ERROR

What does this error means??

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Hi Jos,

I still don't get it. I do now use smtp.gmail.com. I send the message from a Gmail account to another Gmail account but I get the same error:

C:\Program Files\AutoIt3\Include\_INetSmtpMailCom.au3 (55) : ==> The requested action with this object has failed.:
$objEmail.Send
$objEmail.Send^ ERROR

What does this error means??

I see you use _InetSmtpMailCom.au3 as include, but what is its content?

The script I posted in the Examples thread cannot be used as Include without modifications.

Just show the code you have and the include file (without userid/password info) so I can see where things go wrong.

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

My Script:

#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

I use this as include:

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 "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
Edited by Rawox

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

I see you still haven't implemented the ComErrorHandler like in the Example and you also still default to sender email address other than gmail.com

Run with this one from SciTE and look at the COm errors generated when trying to send and Email.

Global $oMyRet[2]
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
;
;
; 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

#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
Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Well,,

I sometimes get this error:

### COM Error !  Number: 80020009   ScriptLine: 55   Description:De server heeft het adres van de afzender geweigerd. Reactie van server: 555 5.5.2 Syntax error. 5sm3134257eyf.8

Blij dat je NL bent Jos

Edited by Rawox

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Hallo Jos

When I using _INetSmtpMailCom in a standalone it works perfect, thanks for that!!

But, when I'm using it in 'XProtec' (also in the free version) it fails: there is no connection possible. In the 'XProtec-free' I've rewrite with your 'MyErrFunc()' but the answer tell nothing specific: Error 80020009, linenumber= -1 (because the #include function(?)).

I've tried to let's work with playing 'smtpconnectiontimeout' and with all other variables set into a fixed value

Have you some other suggests??

Bedankt

edit: typo

Edited by Softieware

Share this post


Link to post
Share on other sites

Hallo Jos

When I using _INetSmtpMailCom in a standalone it works perfect, thanks for that!!

But, when I'm using it in 'XProtec' (also in the free version) it fails: there is no connection possible. In the 'XProtec-free' I've rewrite with your 'MyErrFunc()' but the answer tell nothing specific: Error 80020009, linenumber= -1 (because the #include function(?)).

I've tried to let's work with playing 'smtpconnectiontimeout' and with all other variables set into a fixed value

Have you some other suggests??

Bedankt

edit: typo

Do you have a "simple" snippet that simulates your problem so I can test?

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Do you have a "simple" snippet that simulates your problem so I can test?

Must make that, so within 2 day's I reply. (yesterday I had, but deleted ....)

BTW never herd of this problem by 'XProTec' I think.

When its sending by 'XProTec' I see a shorter network connectivity (~ 30%) than by 'normal' use of the mail-UDF, but thats normal by not sending a mail.

Thnxs for the moment.

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

#include"XProTec3.au3" ; MUST BE AN INCLUDE

$D_Mail = "Opti***.Wijb***@gmail.com " 
$D_Program = "Optimize" ; your program name
$U_Price = "10.00" ; the amount of money you wish to be payed by the user
$U_Trial = "30" ; amount of days for the trial period
$U_License = "3" ; 1 = E-mail ; 2 = user 3 = one computer only - see license notes
$D_License = "2" ; developers license # 
$D_PayPal = "www.paypal.com/my account-link to paypal" ; - paypal link
$D_Link = "www.mywebsite.com/.../" ; looks for "www.mywebsite.com/.../Blacklist.txt" ; see Blacklist
$U_Return = 1 ; pay or quit .... or  $U_Return = 0 ; will return control to developer with @extended = 6 [Limited Freeware Option]



XProTec()

Exit

to call 'XProTec3' and then my 'modifyed' .....

#include-once

Global $oMyRet[2]
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")


Func XProTec()
    mEmailer()
EndFunc   ;==>XProTec
Func mEmailer()
    $objEmail = ObjCreate("CDO.Message")
    $objEmail.From = "Opti****.Wijb***@gmail.com"
    $objEmail.To = "Wijb***@gmail.com"
    Local $i_Error = 0
    Local $i_Error_desciption = ""
    $objEmail.Subject = "test 13"
    $objEmail.TextBody = "lol"
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = "Opti****.Wijb***@gmail.com"
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "Bl******ail"
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = true
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 1000
    $objEmail.Configuration.Fields.Update
    $objEmail.Fields.Update
    $objEmail.Send
    If @error Then 
        SetError(2)
        Return $oMyRet[1]
    EndIf
    $oMyError = ""
    $objEmail = ""
    Exit
EndFunc   ;==>mEmailer
Func MyErrFunc()
    $HexNumber = Hex($oMyError.number, 8)
    $oMyRet[0] = $HexNumber
    $oMyRet[1] = StringStripWS($oMyError.description, 3)
    MsgBox(262209, "COM /Internal Error", "### COM Error !  Number: " & $HexNumber & @CRLF & "   ScriptLine: " & $oMyError.scriptline & @CRLF& "   Description: " & $oMyRet[1] & @LF)
    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

it was/is playing around and around in my head, so I make my snippet!!

Wijbe

edit: typo

Edited by Softieware

Share this post


Link to post
Share on other sites

I am lost when looking at the posted code.

You include XProTec3.au3 in the first code portion, but what is the second bit of code supposed to do?

To make it a little easier just zip up the files I need to test in a PM and tell me what the problem is.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

I am lost when looking at the posted code.

You include XProTec3.au3 in the first code portion, but what is the second bit of code supposed to do?

To make it a little easier just zip up the files I need to test in a PM and tell me what the problem is.

Jos

This is the hole program where the error arises THIS will not work, with error:

Number: 80020009 Scriptline: -1 Description: De transportfunctie kan geen verbinding maken met de server.

When I use the Go button it works fine, but after compiling (needed for 'XProTec') it fails.

So, any suggest?

BTW the other part of the main has computer performance functions and deals not with 'XProTec'

BTW2 how can I send attachments in your box? >_<

Wijbe

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

This is the hole program where the error arises THIS will not work, with error:

Number: 80020009 Scriptline: -1 Description: De transportfunctie kan geen verbinding maken met de server.

When I use the Go button it works fine, but after compiling (needed for 'XProTec') it fails.

So, any suggest?

BTW the other part of the main has computer performance functions and deals not with 'XProTec'

BTW2 how can I send attachments in your box? >_<

Wijbe

You will have to send me the files because you are not making it any clearer at this moment and I am not going to try anything unless I am sure what your issue is and how you are testing. Your choice ... Jos :(

PS: Attaching files is explained on the first post of this topic.

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

You will have to send me the files because you are not making it any clearer at this moment and I am not going to try anything unless I am sure what your issue is and how you are testing. Your choice ... Jos >_<

PS: Attaching files is explained on the first post of this topic.

Sorry, newbie!

i am not meaning sending attachments with your fine program.

Trying with

... "simple" snippet ...
i send here the next example!

I make, test and compile it in 'your' SkiTE.

Hope this is what you meaning (!?!), because I think we mismatch each others.

btw now I have got 2 errors

Edited by Softieware

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

Both message are received fine when I fill in my GMail account info and send them to another Email address.

Not errors at all.

Jos

PS: Its SciTE >_<

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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