B
Ben Edwards
I have the following code:-
dbh = DBI.connect('*', '*', '*')
smtp = Net::SMTP.start('*')
sql = open( "gw.sql", "r" ).read
sth = dbh.execute( sql )
sth.fetch_hash do |row|
mail = MailFactory.new()
mail.to = "(e-mail address removed)"
mail.from = "(e-mail address removed)"
mail.subject = "file from ingenta"
mail.text = "Here is the file"
mail.attach( "./" + row["IDENTITYID"] + "_" + month + year + ".csv" );
smtp.send_message( mail.to_s(), mail.from, mail.to )
end
sth.finish
smtp.finish
dbh.disconnect
This code seems to cause a new object to be created for every
iteration of the iterator. However is it true that 'mail =
MailFactory.new()' causes the previous Mailfactory object not to have
a reference to it and therefore it can be garbage collected?
Is there a better way of coding the above?
Ben
dbh = DBI.connect('*', '*', '*')
smtp = Net::SMTP.start('*')
sql = open( "gw.sql", "r" ).read
sth = dbh.execute( sql )
sth.fetch_hash do |row|
mail = MailFactory.new()
mail.to = "(e-mail address removed)"
mail.from = "(e-mail address removed)"
mail.subject = "file from ingenta"
mail.text = "Here is the file"
mail.attach( "./" + row["IDENTITYID"] + "_" + month + year + ".csv" );
smtp.send_message( mail.to_s(), mail.from, mail.to )
end
sth.finish
smtp.finish
dbh.disconnect
This code seems to cause a new object to be created for every
iteration of the iterator. However is it true that 'mail =
MailFactory.new()' causes the previous Mailfactory object not to have
a reference to it and therefore it can be garbage collected?
Is there a better way of coding the above?
Ben