Here, this is something that I have been working on…You may be able to
modify it to get you in the right direction.
I us FX…nice but you can take it all away and use something else…I
have tried to modularize it as best as I could. ALSO, be careful
because with this one I don’t have server activity checks and if you
send too many Email it clogs your server.
If someone else has something better, please send it up so that I can
learn a little more too.
require ‘fox16’
require ‘fileutils’
require ‘find’
require ‘net/smtp’
include Fox
$emailName = Array::new
#$et = File.read(‘text_par.html’)
class My_FileNames
def getFilenames
FileUtils.cd(‘TEMPTEST’)
Dir.glob(’*.txt’).each do |f|
$combobox.appendItem(f)
end
end
def getFileContent
$mailAddtext.text = ‘’
IO.foreach($combobox.text, ‘\n’) do |line|
$mailAddtext.text = “#{line}\n”
end
end
def sendEmails
$emailName = $mailAddtext.text
$emailName. each do |name|
begin
$address = name.scan(/.*?[^\n]$/).flatten
puts $address
# Net::SMTP.start('MAIL SERVER HERE', 25,
‘localhost’,‘USERNAME’,‘PASSWORD’, :plain) do |smtp|
# smtp.open_message_stream(‘FROM EMAIL ADDRESS’, $address) do |f|
# f.puts ‘From: FROM EMAIL ADDRESS’
# f.puts “To: #{$address}”
# f.puts “MIME-Version: 1.0”
# f.puts “Content-type: text/html”
# f.puts ‘Subject: SUBJECT GOES HERE’
# f.puts
# f.puts “#{$eT}”
# end
# end
#puts message
#p $address
rescue Exception => e
puts "Could not send to #{$address} - #{e.message}\n"
#puts e.backtrace.inspect
end
end
end
end
theApp = FXApp.new
theMainWindow = FXMainWindow.new(theApp, “Email App”)
theMainWindow.position(50,50, 350,200)
groupBxL = FXGroupBox.new(theMainWindow, “Left”,
FRAME_RIDGE|LAYOUT_FIX_X|LAYOUT_FIX_Y|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT,
:x=>0, :y=>0, :width=>175, :height=>200)
groupBxR = FXGroupBox.new(theMainWindow, “Right”,
FRAME_RIDGE|LAYOUT_FIX_X|LAYOUT_FIX_Y|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT,
:x=>180, :y=>0, :width=>155, :height=>200)
$mailAddtext = FXText.new(groupBxL, nil, 0,
FRAME_SUNKEN|FRAME_THICK|LAYOUT_FIX_HEIGHT|JUSTIFY_LEFT|LAYOUT_FILL_COLUMN|LAYOUT_FIX_WIDTH,
:height=>175, :width=>150)
$combobox = FXComboBox.new(groupBxR,20, nil, 0,
COMBOBOX_INSERT_LAST|FRAME_SUNKEN|FRAME_THICK)
My_FileNames.new.getFilenames
$combobox.connect(SEL_COMMAND){My_FileNames.new.getFileContent}
theButton = FXButton.new(groupBxR, “&Exit”)
theButton.tipText = “Exit Program”
theButton.connect(SEL_COMMAND) { exit }
sendMailButton = FXButton.new(groupBxR, “&Send
Emails”,:opts=>BUTTON_NORMAL|LAYOUT_FIX_X|LAYOUT_FIX_Y,:x=>45,:y=>46)
sendMailButton.tipText = “Send To These Emails”
sendMailButton.connect(SEL_COMMAND) {My_FileNames.new.sendEmails}
FXToolTip.new(theApp)
theApp.create
theMainWindow.show
theApp.run