?
Solved

Autoit script to send an email with mutiple FROM addresses.

Posted on 2011-10-25
18
Medium Priority
?
4,257 Views
Last Modified: 2013-11-10
I am looking to create an AutoIT script that sends an email, but gives a drop down of choicses to send FROM. I have the following code that works to send an email, i just need to modify it.

 
#include <INet.au3>
#AutoIt3Wrapper_icon=alert.ico
$begin=MsgBox(0x4, "Alert)", "Are you sure you want to proceed?")
if $begin = 7 then exit
$s_SmtpServer = "mail1"
$s_FromName = "Emergency"
$s_FromAddress = "alert@domain.com"
$s_ToAddress = "alert@domain.com"
$s_Subject = "********* EMERGENCY ALERT *********"
Dim $as_Body[2]
$as_Body[0] = "Attention all employees. An emergency has taken place that requires evacuation of the building,"
$as_Body[1] = "please proceed in an orderly  fashion to the safest exit. Thank you"
$Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, @ComputerName, -1);
$err = @error

Open in new window

0
Comment
Question by:victordr
  • 10
  • 8
18 Comments
 
LVL 29

Expert Comment

by:matrixnz
ID: 37030215
You will need to replace the Emergency, Emergency1, Emergency2 with your own names and also replace the associated email addresses, I've also rem'd the $response line and added the msgbox just for testing.

Cheers
#NoTrayIcon
#AutoIt3Wrapper_icon=alert.ico

#include <ComboConstants.au3>
#include <GuiConstants.au3>
#include <INet.au3>
#include <WindowsConstants.au3>

;~ Email Subject
 Global $VAR_SUBJECTX = "********* EMERGENCY ALERT *********"
;~ Email Send to Email Address (default)
 Global $VAR_SENDMAIL = "alert@domain.com"
;~ Email Body (default)
 Global $VAR_BODYMAIL = "Attention all employees. An emergency has taken place that requires evacuation of the building," & @CRLF & @CRLF
  $VAR_BODYMAIL &= "please proceed in an orderly  fashion to the safest exit." & @CRLF & @CRLF & "Thank you"
;~ Email SMTP Mail Server
 Global $VAR_SMTPMAIL = "mail1"

$begin=MsgBox(0x4, "Alert)", "Are you sure you want to proceed?")
if $begin = 7 then exit

FNC_GUIEMAIL()

Func FNC_GUIEMAIL()
 Local $CHK_BODYMAIL, $CHK_FROMMAIL, $CHK_SENDMAIL
 Local $GUI_BODYMAIL, $GUI_FROMMAIL, $GUI_SENDMAIL
 Local $MSG_FROMNAME, $MSG_FROMMAIL

 GUICreate($VAR_SUBJECTX, 600, 215)

;~ Begin "From:" Gui Information
 GUICtrlCreateLabel('From:', 10, 12, 50, 20)
 $GUI_FROMMAIL = GUICtrlCreateCombo('', 65, 10, 525, 20, $CBS_DROPDOWNLIST)
  GUICtrlSetData($GUI_FROMMAIL, 'Emergency|Emergency1|Emergency2', 'Emergency')
;~ End "From:" Gui Information

;~ Begin "To:" Gui Information
 GUICtrlCreateLabel('To:', 10, 37, 50, 20)
 $GUI_SENDMAIL = GUICtrlCreateInput($VAR_SENDMAIL, 65, 35, 525, 20)
;~ End "To:" Gui Information

;~ Begin "Body:" Gui Information
 GUICtrlCreateLabel('Body', 10, 62, 50, 20)
 $GUI_BODYMAIL = GUICtrlCreateEdit($VAR_BODYMAIL, 65, 62, 525, 100, $WS_VSCROLL)
;~ End "Body:" Gui Information

 $GUI_CLOSEMSG = GUICtrlCreateButton('Cancel', 490, 167, 100, 40)
 $GUI_EMAILMSG = GUICtrlCreateButton('Send', 390, 167, 100, 40)

 GUISetState()
 While 1
  $msg = GUIGetMsg()
  Switch $msg
   Case $GUI_EVENT_CLOSE
    Exit
   Case $GUI_CLOSEMSG
    Exit
   Case $GUI_EMAILMSG
    $CHK_FROMMAIL = GUICtrlRead($GUI_FROMMAIL)
    Select
     Case $CHK_FROMMAIL = 'Emergency'
      $MSG_FROMNAME = 'Emergency'
      $MSG_FROMMAIL = 'alert@domain.com'
     Case $CHK_FROMMAIL = 'Emergency1'
      $MSG_FROMNAME = 'Emergency1'
      $MSG_FROMMAIL = 'alert1@domain.com'
     Case $CHK_FROMMAIL = 'Emergency2'
      $MSG_FROMNAME = 'Emergency2'
      $MSG_FROMMAIL = 'alert2@domain.com'
     Case Else
      $MSG_FROMNAME = 'Emergency'
      $MSG_FROMMAIL = 'alert@domain.com'
    EndSelect
    $MSG_SENDMAIL = GUICtrlRead($GUI_SENDMAIL)
    $MSG_BODYMAIL = GUICtrlRead($GUI_BODYMAIL)
    MsgBox(0, 'Response', 'From: ' & $MSG_FROMNAME & '(' & $MSG_FROMMAIL & ')' & @CRLF & 'To: ' & $MSG_SENDMAIL & @CRLF & @CRLF & $VAR_SUBJECTX & @CRLF & @CRLF & $MSG_BODYMAIL)
  ;$Response = _INetSmtpMail ($VAR_SMTPMAIL, $MSG_FROMNAME, $MSG_FROMMAIL, $MSG_SENDMAIL, $VAR_SUBJECTX, $MSG_BODYMAIL, @ComputerName, -1)
  EndSwitch
 WEnd
EndFunc

Open in new window

0
 

Author Comment

by:victordr
ID: 37030593
I need to add an addtional Send to Email to the drop down list..
0
 

Author Comment

by:victordr
ID: 37030606
I also have a list of 56 FROM email addresses so i just keep adding them with Case $CHK_FROMMAIL?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:victordr
ID: 37030666
It doesn't seem to be sending the email. I put in the name of my exchange server and even tried the IP. same thing.
0
 
LVL 29

Expert Comment

by:matrixnz
ID: 37030755
Haven't tested the emailing, I assumed it was working, can you send through what you have now?
After the $Response line, add something like MsgBox(0,'', @error) to see what the return code is of $Response.

With regards to the 56 yes, or if you wanted, we could put it into an array, for example

Global $STR_FROMMAIL = 'Emergency0;alert0@domain.com|Emergency1;alert1@domain.com;etc...'
Then we can split using the pipe delimiter and then by the semicolon delimiter.
0
 
LVL 29

Expert Comment

by:matrixnz
ID: 37030795
Also for the Send Email you can use the following code, just replace the existing code Starting with ;~ Begin "To:"... to ;~ End "To:"....:
;~ Begin "To:" Gui Information
 GUICtrlCreateLabel('To:', 10, 37, 50, 20)
 $GUI_SENDMAIL = GUICtrlCreateCombo('', 65, 35, 525, 20, $CBS_DROPDOWNLIST)
  GUICtrlSetData($GUI_SENDMAIL, 'alert@domain.com|alert1@domain.com|alert2@domain.com', 'alert@domain.com')
;~ End "To:" Gui Information

Open in new window

0
 

Author Comment

by:victordr
ID: 37030816
#NoTrayIcon
#AutoIt3Wrapper_icon=alert.ico

#include <ComboConstants.au3>
#include <GuiConstants.au3>
#include <INet.au3>
#include <WindowsConstants.au3>

;~ Email Subject
 Global $VAR_SUBJECTX = "Would my supervisor mind stopping by this work center"
;~ Email Send to Email Address (default)
 Global $VAR_SENDMAIL = "maintenancealertsudi@domain.com"
;~ Email Body (default)
 Global $VAR_BODYMAIL = "Would my supervisor mind stopping by this work center," & @CRLF & @CRLF
  $VAR_BODYMAIL &= "Would my supervisor mind stopping by this work center." & @CRLF & @CRLF & "Thank you"
;~ Email SMTP Mail Server
 Global $VAR_SMTPMAIL = "192.168.0.25"

$begin=MsgBox(0x4, "Alert)", "Are you sure you want to proceed?")
if $begin = 7 then exit

FNC_GUIEMAIL()

Func FNC_GUIEMAIL()
 Local $CHK_BODYMAIL, $CHK_FROMMAIL, $CHK_SENDMAIL
 Local $GUI_BODYMAIL, $GUI_FROMMAIL, $GUI_SENDMAIL
 Local $MSG_FROMNAME, $MSG_FROMMAIL

 GUICreate($VAR_SUBJECTX, 600, 215)

;~ Begin "From:" Gui Information
 GUICtrlCreateLabel('From:', 10, 12, 50, 20)
 $GUI_FROMMAIL = GUICtrlCreateCombo('', 65, 10, 525, 20, $CBS_DROPDOWNLIST)
  GUICtrlSetData($GUI_FROMMAIL, 'CAGEUD1|CAGEVS1|Emergency2', 'Emergency')
;~ End "From:" Gui Information

;~ Begin "To:" Gui Information
 GUICtrlCreateLabel('To:', 10, 37, 50, 20)
 $GUI_SENDMAIL = GUICtrlCreateInput($VAR_SENDMAIL, 65, 35, 525, 20)
;~ End "To:" Gui Information

;~ Begin "Body:" Gui Information
 GUICtrlCreateLabel('Body', 10, 62, 50, 20)
 $GUI_BODYMAIL = GUICtrlCreateEdit($VAR_BODYMAIL, 65, 62, 525, 100, $WS_VSCROLL)
;~ End "Body:" Gui Information

 $GUI_CLOSEMSG = GUICtrlCreateButton('Cancel', 490, 167, 100, 40)
 $GUI_EMAILMSG = GUICtrlCreateButton('Send', 390, 167, 100, 40)

 GUISetState()
 While 1
  $msg = GUIGetMsg()
  Switch $msg
   Case $GUI_EVENT_CLOSE
    Exit
   Case $GUI_CLOSEMSG
    Exit
   Case $GUI_EMAILMSG
    $CHK_FROMMAIL = GUICtrlRead($GUI_FROMMAIL)
    Select
     Case $CHK_FROMMAIL = 'CAGEUD1'
      $MSG_FROMNAME = 'CAGEUD1'
      $MSG_FROMMAIL = 'CAGEUD1@domain.com'
     Case $CHK_FROMMAIL = 'CAGEVS1'
      $MSG_FROMNAME = 'CAGEVS1'
      $MSG_FROMMAIL = 'CAGEVS1@domain.com'
     Case $CHK_FROMMAIL = 'Emergency2'
      $MSG_FROMNAME = 'Emergency2'
      $MSG_FROMMAIL = 'alert2@domain.com'
     Case Else
      $MSG_FROMNAME = 'Emergency'
      $MSG_FROMMAIL = 'alert@domain.com'
    EndSelect
    $MSG_SENDMAIL = GUICtrlRead($GUI_SENDMAIL)
    $MSG_BODYMAIL = GUICtrlRead($GUI_BODYMAIL)
    MsgBox(0, 'Response', 'From: ' & $MSG_FROMNAME & '(' & $MSG_FROMMAIL & ')' & @CRLF & 'To: ' & $MSG_SENDMAIL & @CRLF & @CRLF & $VAR_SUBJECTX & @CRLF & @CRLF & $MSG_BODYMAIL)
  ;$Response = _INetSmtpMail ($VAR_SMTPMAIL, $MSG_FROMNAME, $MSG_FROMMAIL, $MSG_SENDMAIL, $VAR_SUBJECTX, $MSG_BODYMAIL, @ComputerName, -1)
MsgBox(0,'', @error)
 EndSwitch
 WEnd
EndFunc

Open in new window

0
 
LVL 29

Expert Comment

by:matrixnz
ID: 37030927
As I mentioned you needed to uncomment the $Response line and remove the MsgBox above it, here is the updated code.

Cheers
#NoTrayIcon
#AutoIt3Wrapper_icon=alert.ico

#include <ComboConstants.au3>
#include <GuiConstants.au3>
#include <INet.au3>
#include <WindowsConstants.au3>

;~ Email Subject
 Global $VAR_SUBJECTX = "********* EMERGENCY ALERT *********"
;~ Email Body (default)
 Global $VAR_BODYMAIL = "Attention all employees. An emergency has taken place that requires evacuation of the building," & @CRLF & @CRLF
  $VAR_BODYMAIL &= "please proceed in an orderly  fashion to the safest exit." & @CRLF & @CRLF & "Thank you"
;~ Email SMTP Mail Server
 Global $VAR_SMTPMAIL = "mail1"

$begin=MsgBox(0x4, "Alert)", "Are you sure you want to proceed?")
if $begin = 7 then exit

FNC_GUIEMAIL()

Func FNC_GUIEMAIL()
 Local $CHK_BODYMAIL, $CHK_FROMMAIL, $CHK_SENDMAIL
 Local $GUI_BODYMAIL, $GUI_FROMMAIL, $GUI_SENDMAIL
 Local $MSG_FROMNAME, $MSG_FROMMAIL, $MSG_RESPONSE

 GUICreate($VAR_SUBJECTX, 600, 215)

;~ Begin "From:" Gui Information
 GUICtrlCreateLabel('From:', 10, 12, 50, 20)
 $GUI_FROMMAIL = GUICtrlCreateCombo('', 65, 10, 525, 20, $CBS_DROPDOWNLIST)
  GUICtrlSetData($GUI_FROMMAIL, 'Emergency|Emergency1|Emergency2', 'Emergency')
;~ End "From:" Gui Information

;~ Begin "To:" Gui Information
 GUICtrlCreateLabel('To:', 10, 37, 50, 20)
 $GUI_SENDMAIL = GUICtrlCreateCombo('', 65, 35, 525, 20, $CBS_DROPDOWNLIST)
  GUICtrlSetData($GUI_SENDMAIL, 'alert@domain.com|alert1@domain.com|alert2@domain.com', 'alert@domain.com')
;~ End "To:" Gui Information

;~ Begin "Body:" Gui Information
 GUICtrlCreateLabel('Body', 10, 62, 50, 20)
 $GUI_BODYMAIL = GUICtrlCreateEdit($VAR_BODYMAIL, 65, 62, 525, 100, $WS_VSCROLL)
;~ End "Body:" Gui Information

 $GUI_CLOSEMSG = GUICtrlCreateButton('Cancel', 490, 167, 100, 40)
 $GUI_EMAILMSG = GUICtrlCreateButton('Send', 390, 167, 100, 40)

 GUISetState()
 While 1
  $msg = GUIGetMsg()
  Switch $msg
   Case $GUI_EVENT_CLOSE
    Exit
   Case $GUI_CLOSEMSG
    Exit
   Case $GUI_EMAILMSG
    $CHK_FROMMAIL = GUICtrlRead($GUI_FROMMAIL)
    Select
     Case $CHK_FROMMAIL = 'Emergency'
      $MSG_FROMNAME = 'Emergency'
      $MSG_FROMMAIL = 'alert@domain.com'
     Case $CHK_FROMMAIL = 'Emergency1'
      $MSG_FROMNAME = 'Emergency1'
      $MSG_FROMMAIL = 'alert1@domain.com'
     Case $CHK_FROMMAIL = 'Emergency2'
      $MSG_FROMNAME = 'Emergency2'
      $MSG_FROMMAIL = 'alert2@domain.com'
     Case Else
      $MSG_FROMNAME = 'Emergency'
      $MSG_FROMMAIL = 'alert@domain.com'
    EndSelect
    $MSG_SENDMAIL = GUICtrlRead($GUI_SENDMAIL)
    $MSG_BODYMAIL = GUICtrlRead($GUI_BODYMAIL)
    $Response = _INetSmtpMail ($VAR_SMTPMAIL, $MSG_FROMNAME, $MSG_FROMMAIL, $MSG_SENDMAIL, $VAR_SUBJECTX, $MSG_BODYMAIL, @ComputerName, -1)
 Switch @error
  Case 1
   $MSG_RESPONSE = 'Error: Invalid Parameters'
  Case 2
   $MSG_RESPONSE = 'Error: Unable to start TCP'
  Case 3
   $MSG_RESPONSE = 'Error: Unable to resolve IP'
  Case 4
   $MSG_RESPONSE = 'Error: Unable to create socket'
  Case Else
   $MSG_RESPONSE = 'Error: Unknown'
 EndSwitch
 If $Response = 1 Then $MSG_RESPONSE = 'Success: Message sent successfully'
 MsgBox(0,$VAR_SUBJECTX, $MSG_RESPONSE)
  EndSwitch
 WEnd
EndFunc

Open in new window

0
 

Author Comment

by:victordr
ID: 37031134
That worked! I can actually get rid of the body msg in in the GUI as i only need the subject now. Also in the TO can i have a name show instead of the email like FROMNAME.  

 I thought i could add something like what you have under $CHK_FROMMAIL but i am just begining in autoit.

 You also mentioned putting in an array instead.
0
 
LVL 29

Expert Comment

by:matrixnz
ID: 37031292
Removed the body and made the Gui smaller, I've also changed the Select to Switch (shorten code) and also added name values to the Send To: drop down list.
#NoTrayIcon
#AutoIt3Wrapper_icon=alert.ico

#include <ComboConstants.au3>
#include <GuiConstants.au3>
#include <INet.au3>
#include <WindowsConstants.au3>

;~ Email Subject
 Global $VAR_SUBJECTX = "********* EMERGENCY ALERT *********"
;~ Email Body (default)
 Global $VAR_BODYMAIL = "Attention all employees. An emergency has taken place that requires evacuation of the building," & @CRLF & @CRLF
  $VAR_BODYMAIL &= "please proceed in an orderly  fashion to the safest exit." & @CRLF & @CRLF & "Thank you"
;~ Email SMTP Mail Server
 Global $VAR_SMTPMAIL = "mail1"

$begin=MsgBox(0x4, "Alert)", "Are you sure you want to proceed?")
if $begin = 7 then exit

FNC_GUIEMAIL()

Func FNC_GUIEMAIL()
 Local $CHK_FROMMAIL, $CHK_SENDMAIL
 Local $GUI_FROMMAIL, $GUI_SENDMAIL
 Local $MSG_FROMNAME, $MSG_FROMMAIL
 Local $MSG_SENDNAME, $MSG_SENDMAIL
 Local $MSG_RESPONSE

 GUICreate($VAR_SUBJECTX, 350, 115)

;~ Begin "From:" Gui Information
 GUICtrlCreateLabel('From:', 10, 12, 50, 20)
 $GUI_FROMMAIL = GUICtrlCreateCombo('', 65, 10, 275, 20, $CBS_DROPDOWNLIST)
  GUICtrlSetData($GUI_FROMMAIL, 'Emergency|Emergency1|Emergency2', 'Emergency')
;~ End "From:" Gui Information

;~ Begin "To:" Gui Information
 GUICtrlCreateLabel('To:', 10, 42, 50, 20)
 $GUI_SENDMAIL = GUICtrlCreateCombo('', 65, 40, 275, 20, $CBS_DROPDOWNLIST)
  GUICtrlSetData($GUI_SENDMAIL, 'SendTo|SendTo1|SendTo2', 'SendTo')
;~ End "To:" Gui Information

 $GUI_CLOSEMSG = GUICtrlCreateButton('Cancel', 240, 67, 100, 40)
 $GUI_EMAILMSG = GUICtrlCreateButton('Send', 140, 67, 100, 40)

 GUISetState()
 While 1
  $msg = GUIGetMsg()
  Switch $msg
   Case $GUI_EVENT_CLOSE
    Exit
   Case $GUI_CLOSEMSG
    Exit
   Case $GUI_EMAILMSG
    $CHK_FROMMAIL = GUICtrlRead($GUI_FROMMAIL)
    Switch $CHK_FROMMAIL
     Case 'Emergency'
      $MSG_FROMNAME = 'Emergency'
      $MSG_FROMMAIL = 'alert@domain.com'
     Case 'Emergency1'
      $MSG_FROMNAME = 'Emergency1'
      $MSG_FROMMAIL = 'alert1@domain.com'
     Case 'Emergency2'
      $MSG_FROMNAME = 'Emergency2'
      $MSG_FROMMAIL = 'alert2@domain.com'
     Case Else
      $MSG_FROMNAME = 'Emergency'
      $MSG_FROMMAIL = 'alert@domain.com'
    EndSwitch
    $CHK_SENDMAIL = GUICtrlRead($GUI_SENDMAIL)
    Switch $CHK_SENDMAIL
     Case 'SendTo'
      $MSG_SENDNAME = 'SendTo'
      $MSG_SENDMAIL = 'alert@domain.com'
     Case 'SendTo1'
      $MSG_SENDNAME = 'SendTo1'
      $MSG_SENDMAIL = 'alert1@domain.com'
     Case 'SendTo2'
      $MSG_SENDNAME = 'SendTo2'
      $MSG_SENDMAIL = 'alert2@domain.com'
     Case Else
      $MSG_SENDNAME = 'SendTo'
      $MSG_SENDMAIL = 'alert@domain.com'
    EndSwitch
;    $Response = MsgBox(0, 'Response', 'From: ' & $MSG_FROMNAME & '(' & $MSG_FROMMAIL & ')' & @CRLF & 'To: ' & $MSG_SENDMAIL & @CRLF & @CRLF & $VAR_SUBJECTX & @CRLF & @CRLF & $VAR_BODYMAIL)
    $Response = _INetSmtpMail ($VAR_SMTPMAIL, $MSG_FROMNAME, $MSG_FROMMAIL, $MSG_SENDMAIL, $VAR_SUBJECTX, $VAR_BODYMAIL, @ComputerName, -1)
 Switch @error
  Case 1
   $MSG_RESPONSE = 'Error: Invalid Parameters'
  Case 2
   $MSG_RESPONSE = 'Error: Unable to start TCP'
  Case 3
   $MSG_RESPONSE = 'Error: Unable to resolve IP'
  Case 4
   $MSG_RESPONSE = 'Error: Unable to create socket'
  Case Else
   $MSG_RESPONSE = 'Error: Unknown'
 EndSwitch
 If $Response = 1 Then $MSG_RESPONSE = 'Success: Message sent successfully'
 MsgBox(0,$VAR_SUBJECTX, $MSG_RESPONSE)
  EndSwitch
 WEnd
EndFunc

Open in new window

0
 

Author Comment

by:victordr
ID: 37031449
Is there a limit of how many i can put on this line?

 GUICtrlSetData($GUI_FROMMAIL, 'CAGEUD1|CASTFABUD1|

 I added them all but in the drop down it isn't showing them all.
0
 

Author Comment

by:victordr
ID: 37031541
nevermind. I have to hit the down arrow to view the rest. i thought it would have a scroll bar on the side.
0
 
LVL 29

Accepted Solution

by:
matrixnz earned 2000 total points
ID: 37031888
There is no limit on the Combos, but you must modify the line as I've done below, however please use the new code below following these steps:
1. Create an file named INI_SENDMAIL.ini
2. Create two sections, FROMMAIL and SENDMAIL as per below, change the FROMName and fromname email addresses as required, do the same for SENDNAME.
3. Save the file in the same folder as your script
4. Run the AutoIT code below

Basically you then just edit the INI file to add/remove names and email addresses, alot easier than modifying the script.

Please note that the _IniReadSectionEx function was written by someone else in the AutoIT Forum, this gets around the 32byte limitation with INIReadSection (standard AutoIT function) allowing it to read large INI files.

[FROMMAIL]
FROMNAME0=fromname0@domain.com
FROMNAME1=fromname1@domain.com
FROMNAME2=fromname2@domain.com
[SENDMAIL]
SENDNAME0=sendname0@domain.com
SENDNAME1=sendname1@domain.com
SENDNAME2=sendname2@domain.com
SENDNAME3=sendname3@domain.com

Open in new window

#NoTrayIcon
#AutoIt3Wrapper_icon=alert.ico

#include <Array.au3>
#include <ComboConstants.au3>
#include <GuiConstants.au3>
#include <INet.au3>
#include <WindowsConstants.au3>

Global $INI_SENDMAIL = @ScriptDir & '\INI_SENDMAIL.ini'
  If FileExists($INI_SENDMAIL) = 0 Then Exit

Global $VAR_FROMMAIL = _IniReadSectionEx($INI_SENDMAIL, 'FROMMAIL')
  If Not IsArray($VAR_FROMMAIL) Then Exit
Global $STR_FROMNAME = ''
Global $DEF_FROMNAME = $VAR_FROMMAIL[1][0]
  For $x = 1 To $VAR_FROMMAIL[0][0]
    $STR_FROMNAME &= $VAR_FROMMAIL[$x][0] & '|'
  Next

Global $VAR_SENDMAIL = _IniReadSectionEx($INI_SENDMAIL, 'SENDMAIL')
  If Not IsArray($VAR_SENDMAIL) Then Exit
Global $STR_SENDNAME = ''
Global $DEF_SENDNAME = $VAR_SENDMAIL[1][0]
  For $x = 1 To $VAR_SENDMAIL[0][0]
    $STR_SENDNAME &= $VAR_SENDMAIL[$x][0] & '|'
  Next

;~ Email Subject
  Global $VAR_SUBJECTX = "********* EMERGENCY ALERT *********"
;~ Email Body (default)
Global $VAR_BODYMAIL = "Attention all employees. An emergency has taken place that requires evacuation of the building," & @CRLF & @CRLF
  $VAR_BODYMAIL &= "please proceed in an orderly  fashion to the safest exit." & @CRLF & @CRLF & "Thank you"
;~ Email SMTP Mail Server
Global $VAR_SMTPMAIL = "mail1"

$begin=MsgBox(0x4, "Alert)", "Are you sure you want to proceed?")
if $begin = 7 then exit

FNC_GUIEMAIL()

Func FNC_GUIEMAIL()
 Local $CHK_FROMMAIL, $CHK_SENDMAIL
 Local $GUI_FROMMAIL, $GUI_SENDMAIL
 Local $MSG_FROMNAME, $MSG_FROMMAIL
 Local $MSG_SENDNAME, $MSG_SENDMAIL
 Local $MSG_RESPONSE

 GUICreate($VAR_SUBJECTX, 350, 115)

;~ Begin "From:" Gui Information
  GUICtrlCreateLabel('From:', 10, 12, 50, 20)
  $GUI_FROMMAIL = GUICtrlCreateCombo('', 65, 10, 275, 20, BitOR($CBS_DROPDOWNLIST,$WS_VSCROLL))
  GUICtrlSetData($GUI_FROMMAIL, $STR_FROMNAME, $DEF_FROMNAME)
;~ End "From:" Gui Information

;~ Begin "To:" Gui Information
  GUICtrlCreateLabel('To:', 10, 42, 50, 20)
  $GUI_SENDMAIL = GUICtrlCreateCombo('', 65, 40, 275, 20, BitOR($CBS_DROPDOWNLIST,$WS_VSCROLL))
  GUICtrlSetData($GUI_SENDMAIL, $STR_SENDNAME, $DEF_SENDNAME)
;~ End "To:" Gui Information

  $GUI_CLOSEMSG = GUICtrlCreateButton('Cancel', 240, 67, 100, 40)
  $GUI_EMAILMSG = GUICtrlCreateButton('Send', 140, 67, 100, 40)

 GUISetState()

While 1
  $msg = GUIGetMsg()
  Switch $msg
    Case $GUI_EVENT_CLOSE
      Exit
    Case $GUI_CLOSEMSG
      Exit
    Case $GUI_EMAILMSG
      $CHK_FROMMAIL = GUICtrlRead($GUI_FROMMAIL)
      For $x = 1 To $VAR_FROMMAIL[0][0]
        If $VAR_FROMMAIL[$x][0] == $CHK_FROMMAIL Then
          $MSG_FROMNAME = $VAR_FROMMAIL[$x][0]
          $MSG_FROMMAIL = $VAR_FROMMAIL[$x][1]
          ExitLoop
        EndIf
      Next
      $CHK_SENDMAIL = GUICtrlRead($GUI_SENDMAIL)
      For $x = 1 To $VAR_FROMMAIL[0][0]
        If $VAR_SENDMAIL[$x][0] == $CHK_SENDMAIL Then
          $MSG_SENDNAME = $VAR_SENDMAIL[$x][0]
          $MSG_SENDMAIL = $VAR_SENDMAIL[$x][1]
          ExitLoop
        EndIf
      Next
;      $Response = MsgBox(0, 'Response', 'From: ' & $MSG_FROMNAME & '(' & $MSG_FROMMAIL & ')' & @CRLF & 'To: ' & $MSG_SENDMAIL & @CRLF & @CRLF & $VAR_SUBJECTX & @CRLF & @CRLF & $VAR_BODYMAIL)
      $Response = _INetSmtpMail ($VAR_SMTPMAIL, $MSG_FROMNAME, $MSG_FROMMAIL, $MSG_SENDMAIL, $VAR_SUBJECTX, $VAR_BODYMAIL, @ComputerName, -1)
      Switch @error
        Case 1
          $MSG_RESPONSE = 'Error: Invalid Parameters'
        Case 2
          $MSG_RESPONSE = 'Error: Unable to start TCP'
        Case 3
          $MSG_RESPONSE = 'Error: Unable to resolve IP'
        Case 4
          $MSG_RESPONSE = 'Error: Unable to create socket'
        Case Else
          $MSG_RESPONSE = 'Error: Unknown'
      EndSwitch
      If $Response = 1 Then $MSG_RESPONSE = 'Success: Message sent successfully'
      MsgBox(0,$VAR_SUBJECTX, $MSG_RESPONSE)
  EndSwitch
WEnd
EndFunc

Func _IniReadSectionEx($v_file, $s_section)
  If Not $v_file Then Return SetError(-1, 0, 0)
  Local $f_exists = FileExists($v_file)
  Local $i_size, $a_secread
  If $f_exists Then
    $i_size = FileGetSize($v_file) / 1024
    If $i_size <= 31 Then
      $a_secread = IniReadSection($v_file, $s_section)
      If @error Then Return SetError(@error, 0, 0)
      If Not IsArray($a_secread) Then Return SetError(-2, 0, 0)
      Return $a_secread
    EndIf
    EndIf

  Local $s_fread
  If Not $f_exists Then
    $s_fread = $v_file
  Else
    $s_fread = FileRead($v_file)
  EndIf

  Local $s_datapatt = "(?is)(?:^|\v)(?!;|#)\h*\[\h*\Q"
  $s_datapatt &= $s_section
  $s_datapatt &= "\E\h*\]\h*\v+(.*?)(?:\z|\v\h*\[)"
  Local $a_data = StringRegExp($s_fread, $s_datapatt, 1)
  If @error Then Return SetError(-3, 0, 0)

  If Not StringInStr($a_data[0], "=", 1, 1) Then
    Return SetError(-4, 0, 0)
  EndIf

  Local $a_lines
  If StringInStr($a_data[0], @CRLF, 1, 1) Then
    $a_lines = StringSplit(StringStripCR($a_data[0]), @LF)
  ElseIf StringInStr($a_data[0], @LF, 1, 1) Then
    $a_lines = StringSplit($a_data[0], @LF)
  Else
    $a_lines = StringSplit($a_data[0], @CR)
  EndIf

  Local $a_key, $a_value
  Local $s_keypatt = "\h*(?!;|#)(.*?)\h*="
  Local $s_valpatt = "\h*=\h*(.*)"
  Local $a_secs[$a_lines[0] + 1][2], $i_add = 0

  For $iline = 1 To $a_lines[0]
    $a_key = StringRegExp($a_lines[$iline], $s_keypatt, 1)
        If @error Then ContinueLoop
    $s_valpatt = "\h*=\h*(.*)"
    $a_value = StringRegExp($a_lines[$iline], $s_valpatt, 1)
        If @error Then ContinueLoop

    If StringLeft($a_key[0], 1) = '"' And StringRight($a_key[0], 1) = '"' Then
      $a_key[0] = StringTrimLeft(StringTrimRight($a_key[0], 1), 1)
    EndIf

    If StringLeft($a_value[0], 1) = '"' And StringRight($a_value[0], 1) = '"' Then
      $a_value[0] = StringTrimLeft(StringTrimRight($a_value[0], 1), 1)
    EndIf

    $i_add += 1
    $a_secs[$i_add][0] = $a_key[0]
    $a_secs[$i_add][1] = $a_value[0]
  Next

  If Not $i_add Then Return SetError(-5, 0, 0)

  ReDim $a_secs[$i_add + 1][2]
    $a_secs[0][0] = $i_add

  Return $a_secs
EndFunc

Open in new window

0
 

Author Comment

by:victordr
ID: 37032262
When i compile this into an EXE, is there a way to include the ini file in it?
0
 
LVL 29

Expert Comment

by:matrixnz
ID: 37032402
You can, but the file needs to be uncompressed before it can be used, so for example replace Lines 10 and 11 with the code below.

When compiled the INI_SENDMAIL.ini file will be included within the script, when run, it will check to see if the file exists if it doesn't it will uncompress the file into the same location as the script.
Global $INI_SENDMAIL = @ScriptDir & '\INI_SENDMAIL.ini'
  If FileExists($INI_SENDMAIL) = 0 Then
    FileInstall('INI_SENDMAIL.ini', @ScriptDir & '\INI_SENDMAIL.ini', 1)
  EndIf
  If FileExists($INI_SENDMAIL) = 0 Then Exit

Open in new window

0
 

Author Comment

by:victordr
ID: 37033605
ok so there is no way to keep it in the EXE? It needs to be extracted?
0
 
LVL 29

Expert Comment

by:matrixnz
ID: 37034139
Ini are always easier to manage, otherwise you'll need to setup arrays like in the code below:

Note the "Local $VAR_XXXXMAIL[xx][2] (where XXXX = FROM or SEND)
[xx] = The total number of entries + 1 for the array in the example 56 entries + 1: $VAR_XXXXMAIL[57][2]
[2] = Two dimensional Array, don't have to worry about this

Also note the $VAR_XXXXMAIL[0][0] = xx (where XXXX = FROM or SEND)
xx = The total number of entries for the array in the example 56 entries: $VAR_XXXXMAIL[0][0] = 56

These two lines are important, otherwise the number in the Array won't match and the script will error.
#NoTrayIcon
#AutoIt3Wrapper_icon=alert.ico

#include <Array.au3>
#include <ComboConstants.au3>
#include <GuiConstants.au3>
#include <INet.au3>
#include <WindowsConstants.au3>

Global $VAR_FROMMAIL = FNC_FROMMAIL()
  If Not IsArray($VAR_FROMMAIL) Then Exit
Global $STR_FROMNAME = ''
Global $DEF_FROMNAME = $VAR_FROMMAIL[1][0]
  For $x = 1 To $VAR_FROMMAIL[0][0]
    $STR_FROMNAME &= $VAR_FROMMAIL[$x][0] & '|'
  Next

Global $VAR_SENDMAIL = FNC_SENDMAIL()
  If Not IsArray($VAR_SENDMAIL) Then Exit
Global $STR_SENDNAME = ''
Global $DEF_SENDNAME = $VAR_SENDMAIL[1][0]
  For $x = 1 To $VAR_SENDMAIL[0][0]
    $STR_SENDNAME &= $VAR_SENDMAIL[$x][0] & '|'
  Next

;~ Email Subject
  Global $VAR_SUBJECTX = "********* EMERGENCY ALERT *********"
;~ Email Body (default)
Global $VAR_BODYMAIL = "Attention all employees. An emergency has taken place that requires evacuation of the building," & @CRLF & @CRLF
  $VAR_BODYMAIL &= "please proceed in an orderly  fashion to the safest exit." & @CRLF & @CRLF & "Thank you"
;~ Email SMTP Mail Server
Global $VAR_SMTPMAIL = "mail1"

$begin=MsgBox(0x4, "Alert)", "Are you sure you want to proceed?")
if $begin = 7 then exit

FNC_GUIEMAIL()

Func FNC_GUIEMAIL()
 Local $CHK_FROMMAIL, $CHK_SENDMAIL
 Local $GUI_FROMMAIL, $GUI_SENDMAIL
 Local $MSG_FROMNAME, $MSG_FROMMAIL
 Local $MSG_SENDNAME, $MSG_SENDMAIL
 Local $MSG_RESPONSE

 GUICreate($VAR_SUBJECTX, 350, 115)

;~ Begin "From:" Gui Information
  GUICtrlCreateLabel('From:', 10, 12, 50, 20)
  $GUI_FROMMAIL = GUICtrlCreateCombo('', 65, 10, 275, 20, BitOR($CBS_DROPDOWNLIST,$WS_VSCROLL))
  GUICtrlSetData($GUI_FROMMAIL, $STR_FROMNAME, $DEF_FROMNAME)
;~ End "From:" Gui Information

;~ Begin "To:" Gui Information
  GUICtrlCreateLabel('To:', 10, 42, 50, 20)
  $GUI_SENDMAIL = GUICtrlCreateCombo('', 65, 40, 275, 20, BitOR($CBS_DROPDOWNLIST,$WS_VSCROLL))
  GUICtrlSetData($GUI_SENDMAIL, $STR_SENDNAME, $DEF_SENDNAME)
;~ End "To:" Gui Information

  $GUI_CLOSEMSG = GUICtrlCreateButton('Cancel', 240, 67, 100, 40)
  $GUI_EMAILMSG = GUICtrlCreateButton('Send', 140, 67, 100, 40)

 GUISetState()

While 1
  $msg = GUIGetMsg()
  Switch $msg
    Case $GUI_EVENT_CLOSE
      Exit
    Case $GUI_CLOSEMSG
      Exit
    Case $GUI_EMAILMSG
      $CHK_FROMMAIL = GUICtrlRead($GUI_FROMMAIL)
      For $x = 1 To $VAR_FROMMAIL[0][0]
        If $VAR_FROMMAIL[$x][0] == $CHK_FROMMAIL Then
          $MSG_FROMNAME = $VAR_FROMMAIL[$x][0]
          $MSG_FROMMAIL = $VAR_FROMMAIL[$x][1]
          ExitLoop
        EndIf
      Next
      $CHK_SENDMAIL = GUICtrlRead($GUI_SENDMAIL)
      For $x = 1 To $VAR_FROMMAIL[0][0]
        If $VAR_SENDMAIL[$x][0] == $CHK_SENDMAIL Then
          $MSG_SENDNAME = $VAR_SENDMAIL[$x][0]
          $MSG_SENDMAIL = $VAR_SENDMAIL[$x][1]
          ExitLoop
        EndIf
      Next
;      $Response = MsgBox(0, 'Response', 'From: ' & $MSG_FROMNAME & '(' & $MSG_FROMMAIL & ')' & @CRLF & 'To: ' & $MSG_SENDMAIL & @CRLF & @CRLF & $VAR_SUBJECTX & @CRLF & @CRLF & $VAR_BODYMAIL)
      $Response = _INetSmtpMail ($VAR_SMTPMAIL, $MSG_FROMNAME, $MSG_FROMMAIL, $MSG_SENDMAIL, $VAR_SUBJECTX, $VAR_BODYMAIL, @ComputerName, -1)
      Switch @error
        Case 1
          $MSG_RESPONSE = 'Error: Invalid Parameters'
        Case 2
          $MSG_RESPONSE = 'Error: Unable to start TCP'
        Case 3
          $MSG_RESPONSE = 'Error: Unable to resolve IP'
        Case 4
          $MSG_RESPONSE = 'Error: Unable to create socket'
        Case Else
          $MSG_RESPONSE = 'Error: Unknown'
      EndSwitch
      If $Response = 1 Then $MSG_RESPONSE = 'Success: Message sent successfully'
      MsgBox(0,$VAR_SUBJECTX, $MSG_RESPONSE)
  EndSwitch
WEnd
EndFunc

Func FNC_FROMMAIL()
  Local $VAR_FROMMAIL[57][2]
  $VAR_FROMMAIL[0][0] = 56
  $VAR_FROMMAIL[1][0] = 'From1'
  $VAR_FROMMAIL[2][0] = 'From2'
  $VAR_FROMMAIL[3][0] = 'From3'
  $VAR_FROMMAIL[4][0] = 'From4'
  $VAR_FROMMAIL[5][0] = 'From5'
  $VAR_FROMMAIL[6][0] = 'From6'
  $VAR_FROMMAIL[7][0] = 'From7'
  $VAR_FROMMAIL[8][0] = 'From8'
  $VAR_FROMMAIL[9][0] = 'From9'
  $VAR_FROMMAIL[10][0] = 'From10'
  $VAR_FROMMAIL[11][0] = 'From11'
  $VAR_FROMMAIL[12][0] = 'From12'
  $VAR_FROMMAIL[13][0] = 'From13'
  $VAR_FROMMAIL[14][0] = 'From14'
  $VAR_FROMMAIL[15][0] = 'From15'
  $VAR_FROMMAIL[16][0] = 'From16'
  $VAR_FROMMAIL[17][0] = 'From17'
  $VAR_FROMMAIL[18][0] = 'From18'
  $VAR_FROMMAIL[19][0] = 'From19'
  $VAR_FROMMAIL[20][0] = 'From20'
  $VAR_FROMMAIL[21][0] = 'From21'
  $VAR_FROMMAIL[22][0] = 'From22'
  $VAR_FROMMAIL[23][0] = 'From23'
  $VAR_FROMMAIL[24][0] = 'From24'
  $VAR_FROMMAIL[25][0] = 'From25'
  $VAR_FROMMAIL[26][0] = 'From26'
  $VAR_FROMMAIL[27][0] = 'From27'
  $VAR_FROMMAIL[28][0] = 'From28'
  $VAR_FROMMAIL[29][0] = 'From29'
  $VAR_FROMMAIL[30][0] = 'From30'
  $VAR_FROMMAIL[31][0] = 'From31'
  $VAR_FROMMAIL[32][0] = 'From32'
  $VAR_FROMMAIL[33][0] = 'From33'
  $VAR_FROMMAIL[34][0] = 'From34'
  $VAR_FROMMAIL[35][0] = 'From35'
  $VAR_FROMMAIL[36][0] = 'From36'
  $VAR_FROMMAIL[37][0] = 'From37'
  $VAR_FROMMAIL[38][0] = 'From38'
  $VAR_FROMMAIL[39][0] = 'From39'
  $VAR_FROMMAIL[40][0] = 'From40'
  $VAR_FROMMAIL[41][0] = 'From41'
  $VAR_FROMMAIL[42][0] = 'From42'
  $VAR_FROMMAIL[43][0] = 'From43'
  $VAR_FROMMAIL[44][0] = 'From44'
  $VAR_FROMMAIL[45][0] = 'From45'
  $VAR_FROMMAIL[46][0] = 'From46'
  $VAR_FROMMAIL[47][0] = 'From47'
  $VAR_FROMMAIL[48][0] = 'From48'
  $VAR_FROMMAIL[49][0] = 'From49'
  $VAR_FROMMAIL[50][0] = 'From50'
  $VAR_FROMMAIL[51][0] = 'From51'
  $VAR_FROMMAIL[52][0] = 'From52'
  $VAR_FROMMAIL[53][0] = 'From53'
  $VAR_FROMMAIL[54][0] = 'From54'
  $VAR_FROMMAIL[55][0] = 'From55'
  $VAR_FROMMAIL[56][0] = 'From56'

  $VAR_FROMMAIL[1][1] = 'from1@domain.com'
  $VAR_FROMMAIL[2][1] = 'from2@domain.com'
  $VAR_FROMMAIL[3][1] = 'from3@domain.com'
  $VAR_FROMMAIL[4][1] = 'from4@domain.com'
  $VAR_FROMMAIL[5][1] = 'from5@domain.com'
  $VAR_FROMMAIL[6][1] = 'from6@domain.com'
  $VAR_FROMMAIL[7][1] = 'from7@domain.com'
  $VAR_FROMMAIL[8][1] = 'from8@domain.com'
  $VAR_FROMMAIL[9][1] = 'from9@domain.com'
  $VAR_FROMMAIL[10][1] = 'from10@domain.com'
  $VAR_FROMMAIL[11][1] = 'from11@domain.com'
  $VAR_FROMMAIL[12][1] = 'from12@domain.com'
  $VAR_FROMMAIL[13][1] = 'from13@domain.com'
  $VAR_FROMMAIL[14][1] = 'from14@domain.com'
  $VAR_FROMMAIL[15][1] = 'from15@domain.com'
  $VAR_FROMMAIL[16][1] = 'from16@domain.com'
  $VAR_FROMMAIL[17][1] = 'from17@domain.com'
  $VAR_FROMMAIL[18][1] = 'from18@domain.com'
  $VAR_FROMMAIL[19][1] = 'from19@domain.com'
  $VAR_FROMMAIL[20][1] = 'from20@domain.com'
  $VAR_FROMMAIL[21][1] = 'from21@domain.com'
  $VAR_FROMMAIL[22][1] = 'from22@domain.com'
  $VAR_FROMMAIL[23][1] = 'from23@domain.com'
  $VAR_FROMMAIL[24][1] = 'from24@domain.com'
  $VAR_FROMMAIL[25][1] = 'from25@domain.com'
  $VAR_FROMMAIL[26][1] = 'from26@domain.com'
  $VAR_FROMMAIL[27][1] = 'from27@domain.com'
  $VAR_FROMMAIL[28][1] = 'from28@domain.com'
  $VAR_FROMMAIL[29][1] = 'from29@domain.com'
  $VAR_FROMMAIL[30][1] = 'from30@domain.com'
  $VAR_FROMMAIL[31][1] = 'from31@domain.com'
  $VAR_FROMMAIL[32][1] = 'from32@domain.com'
  $VAR_FROMMAIL[33][1] = 'from33@domain.com'
  $VAR_FROMMAIL[34][1] = 'from34@domain.com'
  $VAR_FROMMAIL[35][1] = 'from35@domain.com'
  $VAR_FROMMAIL[36][1] = 'from36@domain.com'
  $VAR_FROMMAIL[37][1] = 'from37@domain.com'
  $VAR_FROMMAIL[38][1] = 'from38@domain.com'
  $VAR_FROMMAIL[39][1] = 'from39@domain.com'
  $VAR_FROMMAIL[40][1] = 'from40@domain.com'
  $VAR_FROMMAIL[41][1] = 'from41@domain.com'
  $VAR_FROMMAIL[42][1] = 'from42@domain.com'
  $VAR_FROMMAIL[43][1] = 'from43@domain.com'
  $VAR_FROMMAIL[44][1] = 'from44@domain.com'
  $VAR_FROMMAIL[45][1] = 'from45@domain.com'
  $VAR_FROMMAIL[46][1] = 'from46@domain.com'
  $VAR_FROMMAIL[47][1] = 'from47@domain.com'
  $VAR_FROMMAIL[48][1] = 'from48@domain.com'
  $VAR_FROMMAIL[49][1] = 'from49@domain.com'
  $VAR_FROMMAIL[50][1] = 'from50@domain.com'
  $VAR_FROMMAIL[51][1] = 'from51@domain.com'
  $VAR_FROMMAIL[52][1] = 'from52@domain.com'
  $VAR_FROMMAIL[53][1] = 'from53@domain.com'
  $VAR_FROMMAIL[54][1] = 'from54@domain.com'
  $VAR_FROMMAIL[55][1] = 'from55@domain.com'
  $VAR_FROMMAIL[56][1] = 'from56@domain.com'
  Return $VAR_FROMMAIL
EndFunc

Func FNC_SENDMAIL()
  Local $VAR_SENDMAIL[57][2]
  $VAR_SENDMAIL[0][0] = 56
  $VAR_SENDMAIL[1][0] = 'Send1'
  $VAR_SENDMAIL[2][0] = 'Send2'
  $VAR_SENDMAIL[3][0] = 'Send3'
  $VAR_SENDMAIL[4][0] = 'Send4'
  $VAR_SENDMAIL[5][0] = 'Send5'
  $VAR_SENDMAIL[6][0] = 'Send6'
  $VAR_SENDMAIL[7][0] = 'Send7'
  $VAR_SENDMAIL[8][0] = 'Send8'
  $VAR_SENDMAIL[9][0] = 'Send9'
  $VAR_SENDMAIL[10][0] = 'Send10'
  $VAR_SENDMAIL[11][0] = 'Send11'
  $VAR_SENDMAIL[12][0] = 'Send12'
  $VAR_SENDMAIL[13][0] = 'Send13'
  $VAR_SENDMAIL[14][0] = 'Send14'
  $VAR_SENDMAIL[15][0] = 'Send15'
  $VAR_SENDMAIL[16][0] = 'Send16'
  $VAR_SENDMAIL[17][0] = 'Send17'
  $VAR_SENDMAIL[18][0] = 'Send18'
  $VAR_SENDMAIL[19][0] = 'Send19'
  $VAR_SENDMAIL[20][0] = 'Send20'
  $VAR_SENDMAIL[21][0] = 'Send21'
  $VAR_SENDMAIL[22][0] = 'Send22'
  $VAR_SENDMAIL[23][0] = 'Send23'
  $VAR_SENDMAIL[24][0] = 'Send24'
  $VAR_SENDMAIL[25][0] = 'Send25'
  $VAR_SENDMAIL[26][0] = 'Send26'
  $VAR_SENDMAIL[27][0] = 'Send27'
  $VAR_SENDMAIL[28][0] = 'Send28'
  $VAR_SENDMAIL[29][0] = 'Send29'
  $VAR_SENDMAIL[30][0] = 'Send30'
  $VAR_SENDMAIL[31][0] = 'Send31'
  $VAR_SENDMAIL[32][0] = 'Send32'
  $VAR_SENDMAIL[33][0] = 'Send33'
  $VAR_SENDMAIL[34][0] = 'Send34'
  $VAR_SENDMAIL[35][0] = 'Send35'
  $VAR_SENDMAIL[36][0] = 'Send36'
  $VAR_SENDMAIL[37][0] = 'Send37'
  $VAR_SENDMAIL[38][0] = 'Send38'
  $VAR_SENDMAIL[39][0] = 'Send39'
  $VAR_SENDMAIL[40][0] = 'Send40'
  $VAR_SENDMAIL[41][0] = 'Send41'
  $VAR_SENDMAIL[42][0] = 'Send42'
  $VAR_SENDMAIL[43][0] = 'Send43'
  $VAR_SENDMAIL[44][0] = 'Send44'
  $VAR_SENDMAIL[45][0] = 'Send45'
  $VAR_SENDMAIL[46][0] = 'Send46'
  $VAR_SENDMAIL[47][0] = 'Send47'
  $VAR_SENDMAIL[48][0] = 'Send48'
  $VAR_SENDMAIL[49][0] = 'Send49'
  $VAR_SENDMAIL[50][0] = 'Send50'
  $VAR_SENDMAIL[51][0] = 'Send51'
  $VAR_SENDMAIL[52][0] = 'Send52'
  $VAR_SENDMAIL[53][0] = 'Send53'
  $VAR_SENDMAIL[54][0] = 'Send54'
  $VAR_SENDMAIL[55][0] = 'Send55'
  $VAR_SENDMAIL[56][0] = 'Send56'

  $VAR_SENDMAIL[1][1] = 'send1@domain.com'
  $VAR_SENDMAIL[2][1] = 'send2@domain.com'
  $VAR_SENDMAIL[3][1] = 'send3@domain.com'
  $VAR_SENDMAIL[4][1] = 'send4@domain.com'
  $VAR_SENDMAIL[5][1] = 'send5@domain.com'
  $VAR_SENDMAIL[6][1] = 'send6@domain.com'
  $VAR_SENDMAIL[7][1] = 'send7@domain.com'
  $VAR_SENDMAIL[8][1] = 'send8@domain.com'
  $VAR_SENDMAIL[9][1] = 'send9@domain.com'
  $VAR_SENDMAIL[10][1] = 'send10@domain.com'
  $VAR_SENDMAIL[11][1] = 'send11@domain.com'
  $VAR_SENDMAIL[12][1] = 'send12@domain.com'
  $VAR_SENDMAIL[13][1] = 'send13@domain.com'
  $VAR_SENDMAIL[14][1] = 'send14@domain.com'
  $VAR_SENDMAIL[15][1] = 'send15@domain.com'
  $VAR_SENDMAIL[16][1] = 'send16@domain.com'
  $VAR_SENDMAIL[17][1] = 'send17@domain.com'
  $VAR_SENDMAIL[18][1] = 'send18@domain.com'
  $VAR_SENDMAIL[19][1] = 'send19@domain.com'
  $VAR_SENDMAIL[20][1] = 'send20@domain.com'
  $VAR_SENDMAIL[21][1] = 'send21@domain.com'
  $VAR_SENDMAIL[22][1] = 'send22@domain.com'
  $VAR_SENDMAIL[23][1] = 'send23@domain.com'
  $VAR_SENDMAIL[24][1] = 'send24@domain.com'
  $VAR_SENDMAIL[25][1] = 'send25@domain.com'
  $VAR_SENDMAIL[26][1] = 'send26@domain.com'
  $VAR_SENDMAIL[27][1] = 'send27@domain.com'
  $VAR_SENDMAIL[28][1] = 'send28@domain.com'
  $VAR_SENDMAIL[29][1] = 'send29@domain.com'
  $VAR_SENDMAIL[30][1] = 'send30@domain.com'
  $VAR_SENDMAIL[31][1] = 'send31@domain.com'
  $VAR_SENDMAIL[32][1] = 'send32@domain.com'
  $VAR_SENDMAIL[33][1] = 'send33@domain.com'
  $VAR_SENDMAIL[34][1] = 'send34@domain.com'
  $VAR_SENDMAIL[35][1] = 'send35@domain.com'
  $VAR_SENDMAIL[36][1] = 'send36@domain.com'
  $VAR_SENDMAIL[37][1] = 'send37@domain.com'
  $VAR_SENDMAIL[38][1] = 'send38@domain.com'
  $VAR_SENDMAIL[39][1] = 'send39@domain.com'
  $VAR_SENDMAIL[40][1] = 'send40@domain.com'
  $VAR_SENDMAIL[41][1] = 'send41@domain.com'
  $VAR_SENDMAIL[42][1] = 'send42@domain.com'
  $VAR_SENDMAIL[43][1] = 'send43@domain.com'
  $VAR_SENDMAIL[44][1] = 'send44@domain.com'
  $VAR_SENDMAIL[45][1] = 'send45@domain.com'
  $VAR_SENDMAIL[46][1] = 'send46@domain.com'
  $VAR_SENDMAIL[47][1] = 'send47@domain.com'
  $VAR_SENDMAIL[48][1] = 'send48@domain.com'
  $VAR_SENDMAIL[49][1] = 'send49@domain.com'
  $VAR_SENDMAIL[50][1] = 'send50@domain.com'
  $VAR_SENDMAIL[51][1] = 'send51@domain.com'
  $VAR_SENDMAIL[52][1] = 'send52@domain.com'
  $VAR_SENDMAIL[53][1] = 'send53@domain.com'
  $VAR_SENDMAIL[54][1] = 'send54@domain.com'
  $VAR_SENDMAIL[55][1] = 'send55@domain.com'
  $VAR_SENDMAIL[56][1] = 'send56@domain.com'

  Return $VAR_SENDMAIL
EndFunc

Open in new window

0
 

Author Closing Comment

by:victordr
ID: 37046547
Excellent solution! Thank you so much.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

569 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question