Jump to content

GUICtrlCreateInput and send Input text


Ilounah
 Share

Recommended Posts

Good day forum mates >_< It is possible to use GUICtrlCreateInput to fill up the needed information like emai add of the sender, main body message, sender, etc. here in this code

Im planning to make a simple filled up form using this smtp-mailer with a SEND button GUICtrlCreateButton, Im still newbie please path me in the right code and if you can share even a little information about the code it is very appreciated thanks :sweating:

Link to comment
Share on other sites

The first parameter of GUICtrlCreateInput is the default text you want displayed in the control.

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 Gude
How 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

The first parameter of GUICtrlCreateInput is the default text you want displayed in the control.

I see one post related on my idea sir Fossil Rock made this script

#include 
#Include

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

$MyEmail = GUICreate("My eMail Program", 290, 450)
GUICtrlCreateLabel("From", 16, 16, 31, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlCreateLabel("Address", 16, 40, 49, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlCreateLabel("To", 16, 64, 19, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlCreateLabel("Subject", 16, 136, 47, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlCreateLabel("Body", 16, 184, 32, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlCreateLabel("Attachments", 16, 160, 74, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlCreateLabel("CC", 16, 88, 20, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlCreateLabel("BCC", 16, 112, 28, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$FromName = GUICtrlCreateInput("", 96, 16, 185, 21)
$FromAddress = GUICtrlCreateInput("", 96, 40, 185, 21)
$ToAddress = GUICtrlCreateInput("", 96, 64, 185, 21)
$CcAddress = GUICtrlCreateInput("", 96, 88, 185, 21)
$BccAddress = GUICtrlCreateInput("", 96, 112, 185, 21)
$Subject = GUICtrlCreateInput("", 96, 136, 185, 21)
$Body = GUICtrlCreateEdit("", 96, 184, 185, 113)
$AttachFiles = GUICtrlCreateInput("", 96, 160, 185, 21)
$Send = GUICtrlCreateButton("Send", 8, 416, 75, 25, 0)
$Reset = GUICtrlCreateButton("Reset", 112, 416, 75, 25, 0)
$Exit = GUICtrlCreateButton("Exit", 208, 416, 75, 25, 0)
GUICtrlCreateGroup("", 8, 304, 273, 105)
GUICtrlCreateLabel("SMTP Server", 19, 328, 68, 17)
GUICtrlCreateLabel("User ID", 19, 352, 40, 17)
GUICtrlCreateLabel("Password", 19, 376, 50, 17)
$SmtpServer = GUICtrlCreateInput("", 90, 325, 180, 21)
$Username = GUICtrlCreateInput("", 90, 349, 180, 21)
$Password = GUICtrlCreateInput("", 90, 373, 180, 21)
GUISetState(@SW_SHOW)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Send
$Send = _INetSmtpMailCom(GUICtrlRead($SmtpServer), GUICtrlRead($FromName), GUICtrlRead($FromAddress), GUICtrlRead($ToAddress), GUICtrlRead($Subject), GUICtrlRead($Body), GUICtrlRead($AttachFiles), GUICtrlRead($CcAddress), GUICtrlRead($BccAddress), GUICtrlRead($Username), GUICtrlRead($Password))
Case $Reset
;;;
Case $Exit
Exit
EndSwitch
WEnd

If @error then
msgbox(0,"Error sending message","Error code: " & @error & " Description: " & $Send)
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 ;==>_INetSmtpMailCom

; Com Error Handler
Func MyErrFunc()
$HexNumber = Hex($oMyError.number, 8)
$oMyRet[0] = $HexNumber
$oMyRet[1] = StringStripWS($oMyError.description,3)
ConsoleWrite("### COM Error ! Number: " & $HexNumber & " ScriptLine: " & $oMyError.scriptline & " Description:" & $oMyRet[1] & @LF)
SetError(1); something to check for when this function returns
Return
EndFunc ;==>MyErrFunc

But he said there is a problem it keeps on loop/sending and someone said take a look on this part

[url="http://www.autoitscript.com/autoit3/docs/keywords.htm"][color=#0000FF]Case[/color][/url][color=#000000][size=2][background=rgb(248, 248, 248)] [/background][/size][/color][color=#5A5A5A][size=2]$Send[/size][/color][color=#000000][size=2][background=rgb(248, 248, 248)]             [/background][/size][/color][color=#5A5A5A][size=2]$Send[/size][/color][color=#000000][size=2][background=rgb(248, 248, 248)] [/background][/size][/color][color=#FF8000][size=2]=[/size][/color][color=#000000][size=2][background=rgb(248, 248, 248)] [/background][/size][/color][color=#000000][size=2]_[/size][/color][color=#000000][size=2][background=rgb(248, 248, 248)]INetSmtpMailCom[/background][/size][/color][color=#FF8000][size=2]([/size][/color]
I dont know if the code is updated :sweating:
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...