Android Question What's wrong with this code: SMTP

Beja

Expert
Licensed User
Hi,
Experimenting with the NET library, I found this code uploaded to this forum by a friend.. but trying to run it, it
gave me "not ok" without explanation :)
Any hint appreciated
B4X:
Sub Process_Globals
    Dim Sm As SMTP
End Sub

Sub Globals
    Dim P2 As Phone
	Private Button1 As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("1")
    If FirstTime Then
        Sm.Initialize( "smtp.gmail.com", 587, "yt65red", "llkmnh0l()", "SM")
          Sm.StartTLSMode = True
        Sm.StartTLSMode = True
    End If
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
Sub SM_MessageSent(Success As Boolean)
      If(Success) Then
        Msgbox("Ok","")
    Else
        Msgbox("not ok","")
    End If
End Sub
 Sub Button1_Click
	    Sm.To.Add("7yt5655@gmail.com")
    Sm.Subject = "This is a test"
    Sm.Body = "This is a test of the messagwe body" 
    Sm.Send
End Sub
 

migrec

Member
Licensed User
It is something with your email address or password, i copied your code and changed to my gmail address and it gave me an "ok"
nothing wrong in your code ;)
 

Beja

Expert
Licensed User
Thanks migrec,
The code is not mine, and not working in my device, I don't know why.. I am pretty sure my id and pwd are both correct.
 

Beja

Expert
Licensed User
Hi giga,
I am using gmail for both emails.. send and receive.
 

masterleous

Member
Licensed User
Check your Gmail account settings, Your email address must be capable to allow unsecured applications to send emails. It will work
 
Top