Android Question SMTP - intercepting MessageSent event

boten

Active Member
Licensed User
Longtime User
I have a main activity and a 2nd activity ("sendact") that send e-mails to several addresses.
The "sendact" activity does some processing deciding where to send and uses:

B4X:
.....
Smtp.Send
Activity.Finish
StartActivity(Main)

Activity "sendact" has the Smtp event sub:

B4X:
Sub Smtp_MessageSent(Success As Boolean)
  If Success Then
  ToastMessageShow("Message sent", True)
  Else
  ToastMessageShow("Error: " & LastException.Message , True)
  End If
End Sub

The problem is that since "sendact" is finished, the ToastMessage is not shown. Log says:

sending message to waiting queue (smtp_messagesent)

Only if switched again immediately to "sendact" does the ToastMessage shown.
Is there a way to cause the ToastMessage to be shown even when Main is active again?

I know I can use Activity.Finish & StartActivity(Main) in Sub Smtp_MessageSent
but I want to immediately switch back to Main once Smtp.Send is executed.
 

boten

Active Member
Licensed User
Longtime User
You mean just the code that actually sends the email? (because the activity interacts with the user, choosing from several adresses).
Is it possible(and valid) to put the sending code in a class? then:
1) initialize the class within "sendact", then
2) the class intercepts the messsage_sent and
3) the class does: callsub(Main,....)?
 
Upvote 0
Top