Duplicate Email Attachements

Lorna

New Member
Licensed User
Longtime User
Hello

I really need some help with an email problem I am having.

Some background on the App:

It downloads data via Bluetooth and saves it to a text file in the root of the external storage.

Once the download is complete you have the option to send an email with this text file attached.

The App creates and attaches the correct file and I can then send it from my chosen email client.

The App is designed to overwrite the same file every time data is downloaded by Bluetooth.

The Problem:

If I download for a second time and click SEND the email that is created contains the attachment twice.


My code is below:

B4X:
Sub btnSend_Click
'-------------------------------------------------------
' SEND EMAIL
'-------------------------------------------------------
If MyDownloaded=True Then                              ' If data downloaded
   Message.To.Add(Main.MyEmail)                   ' Set email
   Message.Subject ="Application Data"      ' Set subject
Message.Attachments.Add(File.Combine(File.DirRootExternal, MyFile))
   StartActivity(Message.GetIntent)          ' Send mail
   Activity.finish                        
End If
End Sub

I’m lost on how to fix this and any help would be appreciated.

Regards,
Lorna
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Here:
B4X:
If MyDownloaded=True Then                              ' If data downloaded
 Dim Message As Email 'create a new object
   Message.To.Add(Main.MyEmail)                    ' Set email
   Message.Subject ="Application Data"        ' Set subject
Message.Attachments.Add(File.Combine(File.DirRootExternal, MyFile))
   StartActivity(Message.GetIntent)             ' Send mail
   Activity.finish                                
End If
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…