Android Question Email sending by Net, SMTP

Vili

New Member
I am trying to make email sending work:

Sub Button1_Click

xui.MsgboxAsync("Hello world!", "B4X")
smtpClient.Initialize("smtp.gmail.com", 587, "[email protected]", "xxxxxx", "SMTP")
smtpClient.StartTLSMode = True
smtpClient.To.Add("[email protected]")
smtpClient.Subject ="Test subject"
smtpClient.Body ="TestingBody"
smtpClient.Send

End Sub

I display that MsgBox first, so the function works. I added the net library. No error message, email is still not sent. Can anyone help? I am a beginner in B4A.

Thank you, Vili
PS: Developing just for myself
 

Vili

New Member
Sorry, I formatted below. I tried to follow what you wrote but MessageSent does not get triggered... I don't get any window pop up. Can you fix my code?
Thank you

B4X:
Private Sub Button1_Click
    xui.MsgboxAsync("Hello world!", "B4X")
    smtpClient.Initialize("smtp.gmail.com", 587, "[email protected]", "xxxxxx", "SMTP")
    smtpClient.StartTLSMode = True
    smtpClient.To.Add("[email protected]")
    smtpClient.Subject ="Test subject"
    smtpClient.Body ="TestingBody"
    Dim sf As Object =      smtpClient.Send
    Wait For (sf) MessageSent (Success As Boolean)
        
    If Success Then
        xui.MsgboxAsync("OK", "B4X")
    Else
        xui.MsgboxAsync("Error", "B4X")
    End If
End Sub
 
Upvote 0

Vili

New Member
Erel: many thanks! With logging I could see that it is an auth problem. I had to set up an App password for my GMail account

BTW, I bought B4A in Dec 2013 (info at macasoft dotttttttttt hu. I played with it a little, now will learn in details.

Thank you!
 
Upvote 0
Top