limelect 48 Posted November 15, 2019 (edited) This my mail attached Delphi software. procedure TForm4.CreateEmail(const Recipient, Subject, Content, Attachment: string); var JRecipient: TJavaObjectArray<JString>; Intent: JIntent; Uri: Jnet_Uri; AttachmentFile: JFile; begin JRecipient := TJavaObjectArray<JString>.Create(1); JRecipient.Items[0] := StringToJString(Recipient); Intent := TJIntent.Create; Intent.setAction(TJIntent.JavaClass.ACTION_SEND); Intent.setFlags(TJIntent.JavaClass.FLAG_ACTIVITY_NEW_TASK); Intent.putExtra(TJIntent.JavaClass.EXTRA_EMAIL, JRecipient); Intent.putExtra(TJIntent.JavaClass.EXTRA_SUBJECT, StringToJString(Subject)); Intent.putExtra(TJIntent.JavaClass.EXTRA_TEXT, StringToJString(Content)); Intent.setType(StringToJString('message/rfc822')); if Attachment <> '' then begin AttachmentFile := TJFile.JavaClass.init(StringToJString(Attachment)); Uri := TJnet_Uri.JavaClass.fromFile(AttachmentFile); Intent.putExtra(TJIntent.JavaClass.EXTRA_STREAM, TJParcelable.Wrap((Uri as ILocalObject).GetObjectID)); end; Intent.setType(StringToJString('vnd.android.cursor.dir/email')); SharedActivity.startActivity(Intent); end; Hebrew text 1. Using NORMAL Gamil phone application on attached Hebrew text file. <<<< NO problem 2. Using my Attached function and Gmail application. <<<< Problem The problem when sending text file with Gmail one can see the text and the attachment with no problem. !!!!!!! When sending SAME text file with Delphi software the attachment is OK but the Hebrew text shown is gibberish. IF i attach HTML file same problem HTML file OK but it is shown in the main mail with gibberish for Hebrew. BE AWARE THAT LOADING THE SAME FILES WITH GMAIL BOTH FILES (text and html) ARE SHOWN OK. P.S the mail sent is open in windows. I thing it is NOT a problem of Unicode. Using galaxy s6 phone. Edited November 15, 2019 by limelect Share this post Link to post
Lars Fosdal 1792 Posted November 15, 2019 My guess: String encoding. Explicitly setting to UTF-8 wherever possible should cure it? Share this post Link to post
limelect 48 Posted November 15, 2019 @Lars Fosdal where in the source there is a place for UTF-8? Be aware that i am using the SAME GMAIL phone application. Once from my application and once stand alone application. Share this post Link to post
Lars Fosdal 1792 Posted November 15, 2019 What is the format of the text message itself, i.e. not the attachment, but the body of text? If HTML - does it contain: <meta charset="UTF-8"> If XML - does it contain: <?xml version = "1.0" encoding = "UTF-8" ?> If plain string - Do you explicitly transform the string from the internal unicode string to UTF-8? I also stumbled on this: https://stackoverflow.com/questions/40469867/message-rfc822-ignores-utf-8 See last comment by @Remy Lebeau Quote RFC822 works fine with UTF-8 provided the email is using a compatible transfer encoding (8bit, quoted-printable, or base64) Share this post Link to post
limelect 48 Posted November 15, 2019 @Lars Fosdal HTML yes. '<meta charset="utf-8">' My comments "BE AWARE THAT LOADING THE SAME FILES WITH GMAIL BOTH FILES (text and html) ARE SHOWN OK." I am using on the SAME text file once GMAIL and once GMAIL FROM MY application !!!! That is what bugs me. GMAIL shows the attached text file. it is crazy. since it is the same file. Share this post Link to post
limelect 48 Posted November 15, 2019 (edited) @Lars Fosdal In my opinion some thing is not correct the way i am sending the attach and it has nothing to do with utf-8. I even used this pas file. same result https://github.com/roywoll/wwEmailWithAttachment_fmx Some thing very basic wrong. Edited November 15, 2019 by limelect Share this post Link to post
limelect 48 Posted November 15, 2019 (edited) @Lars FosdalThis is what i get from the above demo when i insert HEBREW text first line of file second line of file second line שלמה ×בייצחק of file The attached is OK And what it suppose to be lines.Add('first line of file'); lines.Add('second line of file'); lines.Add('second line שלמה אבייצחק of file'); ^^^^ Hebrew Edited November 15, 2019 by limelect Share this post Link to post
limelect 48 Posted November 16, 2019 (edited) In my investigation ,whats going on, i wrote an application with Android Studio. I loaded my text file and the result are the same as with Delphi. So one cannot blame Delphi. That is the good news the bad is the gibberish. Edited November 16, 2019 by limelect Share this post Link to post
Remy Lebeau 1397 Posted November 16, 2019 On 11/15/2019 at 2:19 AM, limelect said: @Lars FosdalThis is what i get from the above demo when i insert HEBREW text first line of file second line of file second line שלמה ×בייצחק of file That text *IS* encoded in UTF-8 properly ("" is the byte sequence EF BB BF, which is the UTF-8 BOM). This is just what UTF-8 encoded text looks like when it is mis-interpreted as a Latin encoding, such as ISO-8859-1 or Windows-1252. Which mean you are likely just missing a required "utf-8" charset attribute assigned to the text so the receiver knows it is UTF-8. Share this post Link to post
limelect 48 Posted November 17, 2019 @Remy Lebeau It seem to be more profound of a problem not Delphi only. As i wrote in my last comment i did a small application for Android Studio based on https://www.javacodegeeks.com/2013/10/send-email-with-attachment-in-android.html and it has the same problem. I do not think it is a decoding problem . And why? Attaching the same text file strait from Gmail application in my phone and sending it to my computer , text shown OK attach OK. Using either Delphi or Android Studio applications has this problem. (Using the same Gmail application on the phone). Viewing the mail received text gibberish attach OK. It seems that some thing very profound is missing in all programs. Am i wrong ? Share this post Link to post
limelect 48 Posted November 17, 2019 (edited) @Remy Lebeau reading your comment a few times let me think where in my software should i insert your suggestion? In Intent.setType some how? Just found should i try ? Edited November 17, 2019 by limelect Share this post Link to post
Remy Lebeau 1397 Posted November 22, 2019 On 11/17/2019 at 1:53 AM, limelect said: @Remy Lebeau It seem to be more profound of a problem not Delphi only. As i wrote in my last comment i did a small application for Android Studio based on https://www.javacodegeeks.com/2013/10/send-email-with-attachment-in-android.html and it has the same problem. I do not think it is a decoding problem . And why? Attaching the same text file strait from Gmail application in my phone and sending it to my computer , text shown OK attach OK. Using either Delphi or Android Studio applications has this problem. (Using the same Gmail application on the phone). Viewing the mail received text gibberish attach OK. It seems that some thing very profound is missing in all programs. Am i wrong ? Then I suggest you look at the RAW email data that is in your inbox for any differences between what the Gmail app is sending vs what Delphi/AndroidStudio is sending. Share this post Link to post
limelect 48 Posted November 22, 2019 @Remy Lebeau looking into the raw did not help. The content is -0000000000009167230597ebd2b6 Content-Type: text/html; charset="UTF-8" << this is OK. and the attached is Content-Transfer-Encoding: base64 X-Attachment-Id: 16e9172ed2a2ffb332f1 Content-ID: <16e9172ed2a2ffb332f1> Have you an idea which is the best place to put my problem for Android. Since it seem to be an Android question. P.S do not forget that loading the same text not with our application it is OK. Did i say crazy? May be an Android bug? 1 Share this post Link to post
limelect 48 Posted November 22, 2019 @Remy LebeauBy the way i have an option not to attach but sending just text , the same text. Sending it (not attaching) the Hebrew is OK !! This is what i use procedure TForm4.SpeedButton1Click(Sender: TObject); var {$IFDEF Android} Intent: JIntent; {$ENDIF} begin Intent := TJIntent.Create; Intent.setType(StringToJString('text/html/pdf/plain')); // Defines the data string. Intent.setAction(TJIntent.JavaClass.ACTION_SEND);//ACTION_VIEW); //Defines the Action. Intent.putExtra(TJIntent.JavaClass.EXTRA_TEXT, StringtoJString(Form2.St)); if MainActivity.getPackageManager.queryIntentActivities(Intent, TJPackageManager.JavaClass.MATCH_DEFAULT_ONLY).size > 0 then //Checks if there is at least one application capable of receiving the intent. MainActivity.startActivity(Intent) //Calls startActivity() to send the intent to the system. else ShowMessage('Receiver not found'); end; Share this post Link to post
limelect 48 Posted November 22, 2019 (edited) @Remy Lebeau I took your suggestion I open for edit both mail one with Delphi software the other with google mail. This is the good mail Content-Type: text/html; charset="UTF-8"; name="WriteHTML.html" This is with Delphi attach the bad Content-Type: application/octet-stream; name="WriteHTML.html" I tried Intent.setType(StringToJString('message/rfc822; charset=utf-8')); or Intent.setType(StringToJString('html ..... or text.... And many other combinations nothing. I wander if there is a instruction that changes Content beside Intent.setType ? Edited November 22, 2019 by limelect 1 Share this post Link to post
Remy Lebeau 1397 Posted November 22, 2019 14 hours ago, limelect said: @Remy Lebeau looking into the raw did not help. The content is That is just the body content? What about the headers above the content? Can you please show the actual RAW emails in their entirety? Share this post Link to post
Remy Lebeau 1397 Posted November 22, 2019 14 hours ago, limelect said: Intent.setType(StringToJString('text/html/pdf/plain')); // Defines the data string. "text/html/pdf/plain" is not a valid media type. Where did you ever get that from? Valid media types are like "text/html", "text/plain", "application/pdf", etc Share this post Link to post
limelect 48 Posted November 23, 2019 @Remy Lebeau "text/html/pdf/plain" This was one of my tries. I tried also that 'text/html; charset=utf-8' as for the mail using Thunderbird. The good MIME-Version: 1.0 Date: Fri, 22 Nov 2019 16:21:38 +0200 Message-ID: <CA+BVp2YgbiYM=z7GgmUijBug2vb_8mron2SPc2JUcWBRektLjw@mail.gmail.com> Subject: =?UTF-8?B?16LXoNee15fXlw==?= From: shlomo abuisak <limelect@gmail.com> To: shlomo abuisak <limelect@gmail.com> Content-Type: multipart/mixed; boundary="000000000000d976590597f021ef" --000000000000d976590597f021ef Content-Type: multipart/alternative; boundary="000000000000d976550597f021ed" --000000000000d976550597f021ed Content-Type: text/plain; charset="UTF-8" --000000000000d976550597f021ed Content-Type: text/html; charset="UTF-8" <div dir="auto"></div> --000000000000d976550597f021ed-- --000000000000d976590597f021ef Content-Type: text/html; charset="UTF-8"; name="WriteHTML.html" Content-Disposition: attachment; filename="WriteHTML.html" Content-Transfer-Encoding: base64 X-Attachment-Id: 16e937d58ab2ffb332f1 Content-ID: <16e937d58ab2ffb332f1> PCFET0NUWVBFIGh0bWwgUFVCTElDICItLy9XM0MvL0RURCBIVE1MIDQuMDEvL0VOIiAiaHR0cDov .... the attached The bad MIME-Version: 1.0 Date: Sat, 23 Nov 2019 08:25:49 +0200 Message-ID: <CA+BVp2Z4yov+j1enXhhxoQ4vyb7YJSbaTfiwP=vO9PDcPpvCHg@mail.gmail.com> Subject: =?UTF-8?B?15vXm9ei16LXotei16I=?= From: shlomo abuisak <limelect@gmail.com> To: shlomo abuisak <limelect@gmail.com> Content-Type: multipart/mixed; boundary="0000000000001459090597fd9ad4" --0000000000001459090597fd9ad4 Content-Type: multipart/alternative; boundary="0000000000001459060597fd9ad2" --0000000000001459060597fd9ad2 Content-Type: text/plain; charset="UTF-8" --0000000000001459060597fd9ad2 Content-Type: text/html; charset="UTF-8" <div dir="auto"></div> --0000000000001459060597fd9ad2-- --0000000000001459090597fd9ad4 Content-Type: application/octet-stream; name="WriteHTML.html" Content-Disposition: attachment; filename="WriteHTML.html" Content-Transfer-Encoding: base64 X-Attachment-Id: 16e96f016642ffb332f1 Content-ID: <16e96f016642ffb332f1> PCFET0NUWVBFIGh0bWwgUFVCTElDICItLy9XM0MvL0RURCBIVE1MIDQuMDEvL0VOIiAiaHR0cDov... the attached Share this post Link to post
limelect 48 Posted November 25, 2019 @Remy Lebeau "text/html/pdf/plain" This was one of my tries. I tried also that 'text/html; charset=utf-8' as for the mail using Thunderbird. The good MIME-Version: 1.0 Date: Fri, 22 Nov 2019 16:21:38 +0200 Message-ID: <CA+BVp2YgbiYM=z7GgmUijBug2vb_8mron2SPc2JUcWBRektLjw@mail.gmail.com> Subject: =?UTF-8?B?16LXoNee15fXlw==?= From: shlomo abuisak <limelect@gmail.com> To: shlomo abuisak <limelect@gmail.com> Content-Type: multipart/mixed; boundary="000000000000d976590597f021ef" --000000000000d976590597f021ef Content-Type: multipart/alternative; boundary="000000000000d976550597f021ed" --000000000000d976550597f021ed Content-Type: text/plain; charset="UTF-8" --000000000000d976550597f021ed Content-Type: text/html; charset="UTF-8" <div dir="auto"></div> --000000000000d976550597f021ed-- --000000000000d976590597f021ef Content-Type: text/html; charset="UTF-8"; name="WriteHTML.html" Content-Disposition: attachment; filename="WriteHTML.html" Content-Transfer-Encoding: base64 X-Attachment-Id: 16e937d58ab2ffb332f1 Content-ID: <16e937d58ab2ffb332f1> PCFET0NUWVBFIGh0bWwgUFVCTElDICItLy9XM0MvL0RURCBIVE1MIDQuMDEvL0VOIiAiaHR0cDov .... the attached The bad MIME-Version: 1.0 Date: Sat, 23 Nov 2019 08:25:49 +0200 Message-ID: <CA+BVp2Z4yov+j1enXhhxoQ4vyb7YJSbaTfiwP=vO9PDcPpvCHg@mail.gmail.com> Subject: =?UTF-8?B?15vXm9ei16LXotei16I=?= From: shlomo abuisak <limelect@gmail.com> To: shlomo abuisak <limelect@gmail.com> Content-Type: multipart/mixed; boundary="0000000000001459090597fd9ad4" --0000000000001459090597fd9ad4 Content-Type: multipart/alternative; boundary="0000000000001459060597fd9ad2" --0000000000001459060597fd9ad2 Content-Type: text/plain; charset="UTF-8" --0000000000001459060597fd9ad2 Content-Type: text/html; charset="UTF-8" <div dir="auto"></div> --0000000000001459060597fd9ad2-- --0000000000001459090597fd9ad4 Content-Type: application/octet-stream; name="WriteHTML.html" Content-Disposition: attachment; filename="WriteHTML.html" Content-Transfer-Encoding: base64 X-Attachment-Id: 16e96f016642ffb332f1 Content-ID: <16e96f016642ffb332f1> PCFET0NUWVBFIGh0bWwgUFVCTElDICItLy9XM0MvL0RURCBIVE1MIDQuMDEvL0VOIiAiaHR0cDov... the attached Share this post Link to post
limelect 48 Posted November 25, 2019 @Remy Lebeau I hope i did not bother too much. After profound instigation it seem that my problem was not any sending software but the software tool. Checking on Gmail on the internet it was OK! So i went back to Thunderbird and found that i had to change the font. Tools>Option> Arial Tools>Option>advanced> incoming mail Hebrew 1255 I have been using this software for years and i did not know. So thanks every body for the help. And that the life of our profession Share this post Link to post
Lars Fosdal 1792 Posted November 25, 2019 The devil is indeed in the details. 1 Share this post Link to post