Android Question AddAttachment doesnt work

Knoppi

Active Member
Licensed User
Longtime User
Hello I have a problem with NET.SMTP AddAttachment.
The mail is sent if I omit the line with AddAttachment,
but it is not sent if I insert AddAttachment.

I have no idea why and there is no error message.

B4X:
    Dim Mail As SMTP
    Mail.Initialize( MailServer, MailPort, MailUserName, MailPassword, "SMTP")  ' <-- a gmail.com account ###

    Mail.AuthMethod = Mail.AUTH_LOGIN
    Mail.UseSSL = konto.UseSSL
    Mail.StartTLSMode = konto.UseTLS

    Mail.Sender = MailSender
    Mail.To.Add( ToEmail)
    Mail.Subject = Title
    Mail.Body = EmailText
   
    File.WriteString( File.DirInternal, "Test.txt", EmailText)
    Mail.AddAttachment( File.DirInternal, "Test.txt")     '<--   if I insert this line NO mail will be sent ###

    Mail.Send
    Wait For SMTP_MessageSent( GetSuccess As Boolean)
    If GetSuccess Then
    End If
 

roumei

Active Member
Licensed User
Not a solution but maybe a hint:
Your code works without problems using another email provider instead of gmail. It might be some kind of Google security feature that is blocking the email.
 
Upvote 0
Top