Android Question Send email with SMTP

Marco Maria Vilucchi

Active Member
Licensed User
Hi all,
I'm trying to send an email using SMTP.
It should be a simple thing, but doesn't work.
I have only this log message: sending message to waiting queue (smtp_messagesent)
where am I wrong?
this is my code:

B4X:
Sub Process_Globals
        Dim SMTP As SMTP
End Sub

Sub Globals
End Sub

Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then
        SMTP.Initialize("smtp.gmail.com", 587, "user","password","SMTP")
        SMTP.UseSSL = False   '   Gmail requires SSL.
    End If
    EnviaEMail
End Sub

Sub EnviaEMail
'    SMTP.Initialize("smtp.gmail.com", 587, "user","password","SMTP")
    SMTP.UseSSL = True
    SMTP.AuthMethod=SMTP.AUTH_LOGIN
    SMTP.To.Add("receiver@gmail.com")
    SMTP.Subject = "Ciao"
    SMTP.Body = "Ciao"
    SMTP.AddAttachment(File.DirDefaultExternal,"file.txt")
'    SMTP.AddAttachment(File.DirInternal & "/extfiles/","filename")
    SMTP.Send
End Sub

Sub SMTP_MessageSent(Success As Boolean)
    Dim StatusSend1 As String
    If Success=True Then StatusSend1="SI inviato"
    If Success=False Then StatusSend1="NO inviato"
    Log(StatusSend1)
End Sub
Can someone help me?
Thanks
Marcom
 
Top