Hello everyone,
This is my first experience in B4A.
I'm trying to write a code that sends an email.
This is the code I wrote:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Private xui As XUI
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'Private x As Int,y As Int,z As Int
Public SMTP As SMTP
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Button1_Click
xui.MsgboxAsync("1", "B4X")
SMTP.Initialize("mail.gmail.com", 587, "[email protected]", "xxxxxxx", "SMTP")
SMTP.StartTLSMode = True
SMTP.To.Add("[email protected]")
SMTP.Subject = "asunto"
SMTP.Body = "cuerpo"
SMTP.Send
xui.MsgboxAsync("2", "B4X")
End Sub
The compilation goes through without errors but the email is not sent.
For testing, I wrote in a print line before and after sending the email. When you run the app, something strange happens: the second print happens first, followed by the first print.
Can anyone help me fix the code so that the email will be sent?
Thanks
Dov
This is my first experience in B4A.
I'm trying to write a code that sends an email.
This is the code I wrote:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Private xui As XUI
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'Private x As Int,y As Int,z As Int
Public SMTP As SMTP
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Button1_Click
xui.MsgboxAsync("1", "B4X")
SMTP.Initialize("mail.gmail.com", 587, "[email protected]", "xxxxxxx", "SMTP")
SMTP.StartTLSMode = True
SMTP.To.Add("[email protected]")
SMTP.Subject = "asunto"
SMTP.Body = "cuerpo"
SMTP.Send
xui.MsgboxAsync("2", "B4X")
End Sub
The compilation goes through without errors but the email is not sent.
For testing, I wrote in a print line before and after sending the email. When you run the app, something strange happens: the second print happens first, followed by the first print.
Can anyone help me fix the code so that the email will be sent?
Thanks
Dov