[Gambas-user] send e-mail out of gambas
Roel Zuidema
zuidemach at ...626...
Mon Apr 30 14:51:49 CEST 2012
Thanks a lot.
On Mon, Apr 30, 2012 at 2:43 PM, Fabien Bodard <gambas.fr at ...626...> wrote:
> #!/usr/bin/env gbs3
> ' Gambas module file
>
> USE "gb.db", "gb.net.smtp"
>
> Private hcon As New Connection
> Private hTim as Timer
> Public Sub Main()
> Application.Daemon = True
> hTim = new timer as "Timer1"
> hTim.Delay = 60000
> hTim.Start
> End
>
> Public sub Timer1_Timer()
> Dim hsmtp As Smtpclient
> Dim hResMails As Result
> Dim s As String
> 'print "coucou"
> 'return
> 'Définir la connection
> hcon.type = "mysql"
> hCon.host = "localhost"
> hcon.login = "*****"
> hCon.password = "***"
> hcon.name = "MyDB"
>
> hResMails = db.exec("SELECT * FROM emails")
>
> For Each hResMails
> hsmtp = New SmtpClient
> hsmtp.Host = "mail.toile-libre.org"
> hsmtp.User = "gf_info at ...2827..."
> hsmtp.Password = "***"
> hsmtp.Port = 587
> hsmtp.From = hsmtp.User
> For Each s In Split(hResMails!to)
> hsmtp.To.Add(s)
> Next
> For Each s In Split(hResMails!cc)
> hsmtp.Cc.Add(s)
> Next
> For Each s In Split(hResMails!bcc)
> hsmtp.bcc.Add(s)
> Next
> hsmtp.Subject = iif(hResMails!sujet, hResMails!sujet, "nosubject")
> hsmtp.Add(hResMails!message, "text/plain")
> if hResMails!message_html Then hsmtp.Add(hResMails!message_html,
> "text/html")
> hsmtp.Send()
> Next
> If hResMails.count = 0 Then Return
> hResMails.MoveLast()
> db.Exec("DELETE FROM emails WHERE id<=&1", hResMails!id)
>
> Catch
> Shell "echo " & Error.Backtrace.Join("\n") & Error.Text & Error.Where &
> " >> mailerror.log"
>
> End
>
>
> This is a script deamon i wrote for the gambasforge, that send db stored
> mail every 1 minute to all the site users. (i use bcc for that)
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
More information about the User
mailing list