Android Question The email is not sent (with created file inside) but no error message

Luis Felipe

Member
Licensed User
Longtime User
Hi every body,

Improving my first app, I'm trying to send by email (via the NET library) the now created text file from the sqlite db.
The file is created (I can see it and read directly into the tablet) but when I try to sent it using the SMTP protocol, it doesn't send it.
Using a Try/Catch I got a success message but the fact is that the email is not sent (and obviously not received).
I tried with several emails but none seems working.
What am I missing?
Thanx
B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("GenerarArchivoLayout")

    If FirstTime Then
        'SMTP.Initialize("mail.latbus.com", 587, "[email protected]", "xxxx", "SMTP")
        SMTP.Initialize("smtp.gmail.com", 587, "[email protected]", "xxxx", "SMTP")
        SMTP.StartTLSMode = True
    End If

    create_textfile
  
    Try
    'SMTP.To.Add("[email protected]")
    SMTP.To.Add("[email protected]")
    SMTP.Subject = "Prueba de envio de un archivo de texto desde el tablet"
    SMTP.Body = "Prueba de envio del archivo de texto desde el tablet."
    SMTP.AddAttachment(File.DirRootExternal & "/Encuestas", exportfile)
    SMTP.Send
    Msgbox("Archivo de texto enviado", "Exito")
    Catch
    Log("Text file not sent")
    End Try

End Sub
 

Attachments

  • EncuestaViajerosVBeta.zip
    24.6 KB · Views: 233
Last edited:

Luis Felipe

Member
Licensed User
Longtime User
It seems to work without adding the text file.
The text file exists, so what's wrong ? Or may'be I can't reuse the name of the generated file with the variable
B4X:
exportfile
?
 
Upvote 0

Luis Felipe

Member
Licensed User
Longtime User
Are you handling the MessageSent event? Is Success true there?

What is the output of: Log(File.Exists(File.DirRootExternal & "/Encuestas", exportfile)) ?

Hi Erel,
Sorry for the late answer (I was sick yesterday :-(). I did not manage the MessageEvent but now I do. It gave me "false" but I found the reason.
Thank you very much.
Extra answer: I can see the generated text file directly in that folder within the tablet but not directly from the Windows desktop PC : is there a way to change that ?
Same question for the sqlite db I create (directly via a "Create table" script within the Activity). Is there a way to see it (I tried Android SQLite Viewer but it can't see it)
? because managing a sqlite db via an Activity is not so easy. At least a way to duplicate it elsewhere?
For example I try to create the text file in the sd card of the tablet but I did not manage it...
Thanx in advance.
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0
Top