Android Question What's wrong with this code: SMTP

Beja

Expert
Licensed User
Longtime 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
Longtime 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
 
Upvote 0

Beja

Expert
Licensed User
Longtime 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.
 
Upvote 0

Beja

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

masterleous

Member
Licensed User
Longtime User
Check your Gmail account settings, Your email address must be capable to allow unsecured applications to send emails. It will work
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…