teapot Posted July 29, 2013 Share Posted July 29, 2013 Hi All, I am new to autoit and also new to programming. I am trying to write the script which will send email to my gmail/Hotmail accounts. I found the following script, but it doesn't work. It gives error- Array variable subscript badly formatted. Please help me! Thanks, #include <array.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #Include <WinAPI.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Include <file.au3> #include <INet.au3> Global $Form1 = GUICreate("Your Mailer", 625, 300, 192, 124) Global $Input1 = GUICtrlCreateInput("My Name", 8, 8, 601, 21) Global $Input2 = GUICtrlCreateInput("My Adresse", 8, 40, 601, 21) Global $Input3 = GUICtrlCreateInput("For the Adresse", 8, 72, 601, 21) Global $Input4 = GUICtrlCreateInput("Subject", 8, 104, 601, 21) Global $Input5 = GUICtrlCreateInput("Message", 8, 136, 601, 21) Global $button1 = GUICtrlCreateButton("Send",8, 200,601,50) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() If $msg = -3 Then DirRemove( @DesktopDir & "ATPATP_Mailer", 1) GUIDelete($Form1) ExitLoop EndIf If $msg = $Button1 Then DirCreate(@DesktopDir & "ATPATP_Mailer") InetGet("http://www.gmail.com/",@DesktopDir & "ATPATP_Mailersmtp") GUICtrlSetState($Button1, $GUI_DISABLE) Global $s_SmtpServer = FileRead( @DesktopDir & "ATPATP_Mailersmtp") Global $s_FromName=GUICtrlRead($Input1) Global $s_FromAddress=GUICtrlRead($Input2) Global $s_ToAddress=GUICtrlRead($Input3) Global $s_Subject = GUICtrlRead($Input4) Global $s_Body[0]= GUICtrlRead($Input5) Global $Response = _INetSmtpMail($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body) sleep(50) GUICtrlSetState($Button1, $GUI_Enable) if @error Then MsgBox(0,"","error "& @error ) Else MsgBox(0,"","1 mail sended") EndIf EndIf WEnd Link to comment Share on other sites More sharing options...
abberration Posted July 30, 2013 Share Posted July 30, 2013 Not testing anything, I can see a problem with the InetGet part. Try replacing two lines of code that I commented out with the new line: expandcollapse popup#include <array.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <WinAPI.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <file.au3> #include <INet.au3> Global $Form1 = GUICreate("Your Mailer", 625, 300, 192, 124) Global $Input1 = GUICtrlCreateInput("My Name", 8, 8, 601, 21) Global $Input2 = GUICtrlCreateInput("My Adresse", 8, 40, 601, 21) Global $Input3 = GUICtrlCreateInput("For the Adresse", 8, 72, 601, 21) Global $Input4 = GUICtrlCreateInput("Subject", 8, 104, 601, 21) Global $Input5 = GUICtrlCreateInput("Message", 8, 136, 601, 21) Global $button1 = GUICtrlCreateButton("Send", 8, 200, 601, 50) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() If $msg = -3 Then DirRemove(@DesktopDir & "\ATP\ATP_Mailer", 1) GUIDelete($Form1) ExitLoop EndIf If $msg = $button1 Then DirCreate(@DesktopDir & "\ATP\ATP_Mailer") ; InetGet("http://www.gmail.com/", @DesktopDir & "\ATP\ATP_Mailer\smtp") GUICtrlSetState($button1, $GUI_DISABLE) ; Global $s_SmtpServer = FileRead(@DesktopDir & "\ATP\ATP_Mailer\smtp") $s_SmtpServer = "smtp.gmail.com" ; new line - this is gmail's SMTP server address Global $s_FromName = GUICtrlRead($Input1) Global $s_FromAddress = GUICtrlRead($Input2) Global $s_ToAddress = GUICtrlRead($Input3) Global $s_Subject = GUICtrlRead($Input4) Global $s_Body[0] = GUICtrlRead($Input5) Global $Response = _INetSmtpMail($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body) Sleep(50) GUICtrlSetState($button1, $GUI_Enable) If @error Then MsgBox(0, "", "error " & @error) Else MsgBox(0, "", "1 mail sended") EndIf EndIf WEnd Easy MP3 | Software Installer | Password Manager Link to comment Share on other sites More sharing options...
BrewManNH Posted July 30, 2013 Share Posted July 30, 2013 _InetSMTPMail won't work with Gmail, you'd need something like the function posted >here. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
teapot Posted August 2, 2013 Author Share Posted August 2, 2013 Not testing anything, I can see a problem with the InetGet part. Try replacing two lines of code that I commented out with the new line: expandcollapse popup#include <array.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <WinAPI.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <file.au3> #include <INet.au3> Global $Form1 = GUICreate("Your Mailer", 625, 300, 192, 124) Global $Input1 = GUICtrlCreateInput("My Name", 8, 8, 601, 21) Global $Input2 = GUICtrlCreateInput("My Adresse", 8, 40, 601, 21) Global $Input3 = GUICtrlCreateInput("For the Adresse", 8, 72, 601, 21) Global $Input4 = GUICtrlCreateInput("Subject", 8, 104, 601, 21) Global $Input5 = GUICtrlCreateInput("Message", 8, 136, 601, 21) Global $button1 = GUICtrlCreateButton("Send", 8, 200, 601, 50) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() If $msg = -3 Then DirRemove(@DesktopDir & "\ATP\ATP_Mailer", 1) GUIDelete($Form1) ExitLoop EndIf If $msg = $button1 Then DirCreate(@DesktopDir & "\ATP\ATP_Mailer") ; InetGet("http://www.gmail.com/", @DesktopDir & "\ATP\ATP_Mailer\smtp") GUICtrlSetState($button1, $GUI_DISABLE) ; Global $s_SmtpServer = FileRead(@DesktopDir & "\ATP\ATP_Mailer\smtp") $s_SmtpServer = "smtp.gmail.com" ; new line - this is gmail's SMTP server address Global $s_FromName = GUICtrlRead($Input1) Global $s_FromAddress = GUICtrlRead($Input2) Global $s_ToAddress = GUICtrlRead($Input3) Global $s_Subject = GUICtrlRead($Input4) Global $s_Body[0] = GUICtrlRead($Input5) Global $Response = _INetSmtpMail($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body) Sleep(50) GUICtrlSetState($button1, $GUI_Enable) If @error Then MsgBox(0, "", "error " & @error) Else MsgBox(0, "", "1 mail sended") EndIf EndIf WEnd Did not work. got error --Array variable subscript badly formatted.: Global $s_Body[0]= GUICtrlRead($Input5) Global $s_Body[^ ERROR Link to comment Share on other sites More sharing options...
teapot Posted August 2, 2013 Author Share Posted August 2, 2013 _InetSMTPMail won't work with Gmail, you'd need something like the function posted >here. Yes, It work's. Thanks a lot!!!!!!!!! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now