sub class_globals
dim smtp as SMTP
dim newMail, busy as boolean = false
dim T1 as timer
end sub
Public Sub Initialize
smtp.Initialize("xxx.xxx.xxx.xxx", port, "[email protected]", "pass", "SMTP")
smtp.StartTLSMode = True
T1.Initialize("sender",1*DateTime.TicksPerMinute)
T1.Enabled=True
End Sub
sub sender_Tick
if newMail = true and busy = false then
newMail = false
wait for (getMAilList) Complete (mailList as list) 'get mailList from DB
sendMailList(mailList)
End if
End Sub
Sub sendMailList (correos as list)
busy = true
DateTime.DateFormat= "EEE, dd MMM yyyy HH:mm:ss Z"
Dim date As String = DateTime.Date(DateTime.Now)
Log(date)
Log(correos)
Dim mensaje As String = "message"
Dim email As String
For x=0 To correos.Size-1
Sleep(5000)
email=correos.Get(x)
email=email.Trim
Try
smtp.To.Add(email)
Dim MAPHEADER As Map
MAPHEADER.Initialize
MAPHEADER.Put("Content-Transfer-Encoding", "7bit")' ESTE HEADER PERMITE QUE GMAIL LEA LOS ARCHIVOS HTML SIN PROBLEMAS
MAPHEADER.Put("Date", date)
smtp.AdditionalHeaders = MAPHEADER
smtp.Sender="Name <[email protected]>"
smtp.Subject = "subject"
smtp.HtmlBody=True
smtp.Body = mensaje
wait for (smtp.Send) SMTP_MessageSent (Success As Boolean)
Log(Success)
If Success Then
Log("EMAIL Message sent successfully")
Else
Log("Error sending EMAIL message")
Log(LastException.Message)
End If
Catch
Log("ERROR:")
Log(LastException.Message)
End Try
Next
busy = false
End Sub