Jump to content
limelect

Hebrew in mail

Recommended Posts

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 by limelect

Share this post


Link to post

@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

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

@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

@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 by limelect

Share this post


Link to post

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 by limelect

Share this post


Link to post
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

@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

@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 by limelect

Share this post


Link to post
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

@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?
 

 

  • Like 1

Share this post


Link to post

@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

@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 by limelect
  • Like 1

Share this post


Link to post
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
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

@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

@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

@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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×