boten Active Member Licensed User Longtime User Sep 26, 2013 #1 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: Code: Copy ..... Smtp.Send Activity.Finish StartActivity(Main) Activity "sendact" has the Smtp event sub: Code: Copy 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.
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: Code: Copy ..... Smtp.Send Activity.Finish StartActivity(Main) Activity "sendact" has the Smtp event sub: Code: Copy 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.
Erel B4X founder Staff member Licensed User Longtime User Sep 26, 2013 #2 Move the code to a service instead of an activity. Upvote 0
boten Active Member Licensed User Longtime User Sep 26, 2013 #3 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
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,....)?
Erel B4X founder Staff member Licensed User Longtime User Sep 28, 2013 #4 You should move the SMTP code to a service. You can use CallSubDelayed to call the relevant sub(s) in the service from the activity. Upvote 0
You should move the SMTP code to a service. You can use CallSubDelayed to call the relevant sub(s) in the service from the activity.