Android Question Mail attachment "intent" concern

freedom2000

Well-Known Member
Licensed User
Longtime User
HI all,

I use this piece of code to attach a binary file to a mail for which I want the user to be able to choose the mail App. Thus I use an intent.

B4X:
Sub PC_click   
    Try
        Dim EMailAddrTo, Subject, Body As String
        'EMailAddrTo = "[email protected]"
       
        Subject = "PowerPoint Mouse PC server executable"
        Body = "Please find attached the PC server executable file" & CRLF & "Save the file and launch it." & CRLF & CRLF & "Then launch the Android App to automatically connect."
        Dim message As Email
        message.To.Add(EMailAddrTo)
        message.Subject = Subject
        message.Body = Body
        message.Attachments.Initialize
        message.Attachments.Add(File.Combine(PowerPointMouseDir, "PowerPointMouse PCserver.exe")) 
        StartActivity(message.GetIntent)
    Catch
        ToastMessageShow("Unable to send mail...", False)
    End Try
End Sub

The behavior is quite good but :

1) a few mail app do not allow to send .exe files ... this is the case of my Nexus5 stock mail App
2) Other App allow to send .exe files (eg K9-Mail or Google drive) but the mail when received on a PC contains a .txt file...

To be clear I can save the attachment on my hard drive but I have to rename the extension from .exe.txt to .exe
Even worse with google drive the file is saved with "name.txt". And I have to know that it is a .exe extension.

The same file sent directly with the same mail App is properly attached and received with the good extension ".exe"

Do you have any idea why the attachment is forced to .txt ?

Thanks
 

freedom2000

Well-Known Member
Licensed User
Longtime User
This is the problem with solutions that rely on third party apps. You don't have full control on the actual behavior.

Make sure that it is not the recipient mail client who adds the txt extension.

No it is not the recipient who adds the txt extension.
In fact when I send the same file with the same K9-Mail App it is sent perfectly.
When I send it with the "intent" it is shown directly in the mail "as a .txt" but of course unreadable.
 
Upvote 0
Top