save Outlook Attachment with "Umlaute"

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
AUGE_OHR
Posts: 2060
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: save Outlook Attachment with "Umlaute"

Post by AUGE_OHR »

hi,

i have got your Demo running but still have Problem.
CMD_Ueber.JPG
CMD_Ueber.JPG (82.05 KiB) Viewed 1716 times
it is a "Legacy" Console with Codepage 850 using Lucida Console Font

---

your Demo Code is in UTF8, right :?:
i have install Notepad++ to use UTF8. i have change Way to send Password from

Code: Select all

*cUrl:= cPOP3 + STRTRAN(tuser,'@','&at;')+ ':' + tpass + '@' + tpop3 + ':' + n2c (tport)
cUrl := cPOP3 + tpop3 + ':' + ALLTRIM( STR( tport ) )
and add PW here

Code: Select all

oPopServer:oUrl:cUserID := tuser
// add PW here
oPopServer:oUrl:cPassword := tpass
oPopServer:nConnTimeout := ttimeout
now i can login at my Provider an got Attachment.
it look fine in Explorer, TC or in a GRID of HMG but still can´t FOPEN() it :evil:

so i´m still make something wrong ... i have to learn more how to use Codepage
thx again for help

---

as i found out Problem is on APPLE side. i found this in a German Apple Forum
Bei Apple Mail triffst du die Vorgabe über das Programm Terminal.
Beende Apple Mail, starte Terminal und gib den folgenden Befehl ein:

Code: Select all

defaults write com.apple.mail NSPreferredMailCharset “ISO-8859-1”
Alternativ kannst du auch Unicode als Codierung wählen. Dazu dient folgender Befehl:

Code: Select all

defaults write com.apple.mail NSPreferredMailCharset “UTF-8”
Sollte es nötig sein, die Standard-Einstellung wiederherzustellen, verwendest du diesen Befehl:

Code: Select all

defaults delete com.apple.mail NSPreferredMailCharset
after tell my Friend to set "UTF8" it seems to work now
have fun
Jimmy
edk
Posts: 909
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: save Outlook Attachment with "Umlaute"

Post by edk »

AUGE_OHR wrote: Sun Oct 11, 2020 8:29 pm hi,

i have got your Demo running but still have Problem.
Check out my binaries. The application downloads attachments from the web.de mail server.

What is the "OS Code Page" displayed when you get e-mails?

Have you checked on a different machine or OS?
your Demo Code is in UTF8, right :?:
Yeap
as i found out Problem is on APPLE side. i found this in a German Apple Forum
Bei Apple Mail triffst du die Vorgabe über das Programm Terminal.
Beende Apple Mail, starte Terminal und gib den folgenden Befehl ein:

Code: Select all

defaults write com.apple.mail NSPreferredMailCharset “ISO-8859-1”
Alternativ kannst du auch Unicode als Codierung wählen. Dazu dient folgender Befehl:

Code: Select all

defaults write com.apple.mail NSPreferredMailCharset “UTF-8”
Sollte es nötig sein, die Standard-Einstellung wiederherzustellen, verwendest du diesen Befehl:

Code: Select all

defaults delete com.apple.mail NSPreferredMailCharset
after tell my Friend to set "UTF8" it seems to work now
Your attachment file name from iOS is wrote in MIME quoted-printable UTF-8
Maybe when you forwarded the message it is already OK?
Attachments
jimmy2.7z
(1.86 MiB) Downloaded 109 times
Last edited by edk on Sun Oct 11, 2020 10:26 pm, edited 3 times in total.
User avatar
AUGE_OHR
Posts: 2060
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: save Outlook Attachment with "Umlaute"

Post by AUGE_OHR »

hi,

still working on that Problem ... i have add this Code

Code: Select all

IF !Empty( oPart:getFileName() ) .AND. UPPER( cDispos ) == 'ATTACHMENT'
   cZalacznik := ValidFileName ( dekodujMIME( oPart:getFileName() ) )
   // Jimmy
   IF CHR(204) $ cZalacznik
      DoTestSign(cZalacznik)        // just show
   ENDIF
Still204.JPG
Still204.JPG (42.42 KiB) Viewed 1712 times
as you can see i still got CHR(204) so my CMD Box is right.

but IMHO i can´t open a Filename which have CHR(204), or :?:

---

i have look at Demo Source from EDK and got it for my own App to download those Files.
i saw

Code: Select all

	set( _SET_CODEPAGE, aCP [i] )
	aDir := DIRECTORY( cWorkPath + "*.*", "DHS" )
does it mean :
DIRECTORY() depend on Codepage :?:
if Yes also FOPEN() :?:

when have aDir : can i "on-fly" use _SET_CODEPAGE :idea:

---

in HBFM i use ShFileOperation to Copy/Move/Delete but it fail also with those filename :(
is this also a Problem of Codepage :?:
have fun
Jimmy
edk
Posts: 909
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: save Outlook Attachment with "Umlaute"

Post by edk »

AUGE_OHR wrote: Sun Oct 11, 2020 10:01 pm hi,

still working on that Problem ... i have add this Code

Code: Select all

IF !Empty( oPart:getFileName() ) .AND. UPPER( cDispos ) == 'ATTACHMENT'
   cZalacznik := ValidFileName ( dekodujMIME( oPart:getFileName() ) )
   // Jimmy
   IF CHR(204) $ cZalacznik
      DoTestSign(cZalacznik)        // just show
   ENDIF
as you can see i still got CHR(204) so my CMD Box is right.

but IMHO i can´t open a Filename which have CHR(204), or :?:
For Überschätzung.pdf filename I have this:
Überschätzung.png
Überschätzung.png (25.38 KiB) Viewed 1710 times
i have look at Demo Source from EDK and got it for my own App to download those Files.
i saw

Code: Select all

	set( _SET_CODEPAGE, aCP [i] )
	aDir := DIRECTORY( cWorkPath + "*.*", "DHS" )
does it mean :
DIRECTORY() depend on Codepage :?:
if Yes also FOPEN() :?:

when have aDir : can i "on-fly" use _SET_CODEPAGE :idea:
Yeap
User avatar
AUGE_OHR
Posts: 2060
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: save Outlook Attachment with "Umlaute"

Post by AUGE_OHR »

hi,

Thx for Answer,

but your Snapshot is total different :o

what i´m doing wrong ... i use your Code and get total different Result ... hm
have fun
Jimmy
edk
Posts: 909
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: save Outlook Attachment with "Umlaute"

Post by edk »

Have you checked this post http://hmgforum.com/viewtopic.php?p=63705#p63705 ?

What are your attachment names read from oPart: getFileName () in MIME mode (before converting by dekodujMIME (oPart: getFileName ())?

I have the following:

Code: Select all


#################################################

Att # 1
UTF8 (after decode MIME):
Rot-Grün – die letzte Bastion der „Biodeutschen“ - Hamburger Abendblatt.pdf

RAW MIME (before decode MIME):
=?utf-8?Q?Rot-Gr=C3=BCn_=E2=80=93_die_letzte_Bastion_der_=E2=80=9EBiodeutschen=E2=80=9C_-_Hamburger_Abendblatt.pdf?=

#################################################

Att # 2
UTF8 (after decode MIME):
Überschätzung.pdf

RAW MIME (before decode MIME):
=?utf-8?Q?=C3=9Cbersch=C3=A4tzung.pdf?=

User avatar
AUGE_OHR
Posts: 2060
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: save Outlook Attachment with "Umlaute"

Post by AUGE_OHR »

edk wrote: Mon Oct 12, 2020 7:20 am Have you checked this post http://hmgforum.com/viewtopic.php?p=63705#p63705 ?
oooooh, sorry :o
i just saw Demo.exe and DLL so i was confused about it.

it was still in my Download Folder, now i see you have prepare a Download and that WORK :D

edk wrote: Mon Oct 12, 2020 7:20 am What are your attachment names read from oPart: getFileName () in MIME mode (before converting by dekodujMIME (oPart: getFileName ())?
I have the following:

Code: Select all

#################################################
Att # 1
UTF8 (after decode MIME):
Rot-Grün – die letzte Bastion der „Biodeutschen“ - Hamburger Abendblatt.pdf

RAW MIME (before decode MIME):
=?utf-8?Q?Rot-Gr=C3=BCn_=E2=80=93_die_letzte_Bastion_der_=E2=80=9EBiodeutschen=E2=80=9C_-_Hamburger_Abendblatt.pdf?=

#################################################

Att # 2
UTF8 (after decode MIME):
Überschätzung.pdf

RAW MIME (before decode MIME):
=?utf-8?Q?=C3=9Cbersch=C3=A4tzung.pdf?=
ok i will check it but i must upload files again
i will come back when have Result
have fun
Jimmy
User avatar
AUGE_OHR
Posts: 2060
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: save Outlook Attachment with "Umlaute"

Post by AUGE_OHR »

here my Snapshot

Rot-Grün – die letzte Bastion der „Biodeutschen“ - Hamburger Abendblatt.pdf
Rot_Gruen.jpg
Rot_Gruen.jpg (25.78 KiB) Viewed 1680 times
Überschätzung.pdf
Ueberschaetzung.jpg
Ueberschaetzung.jpg (13.58 KiB) Viewed 1680 times
hm ... it is different but i have not change your Code only Login User / PW for my Provider.

did you have a newer Version or still use Code above :?:
can it be my Provider :idea:
have fun
Jimmy
edk
Posts: 909
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: save Outlook Attachment with "Umlaute"

Post by edk »

The Code is still the same.
It seems the MultiParts headers have changed after forwarding the message to me.

I am sending you the access data for my test account on web.de via PM

Check from my account.
You can also try to save original whole messages with attachments in .eml format.

Code: Select all

(...)

IF Empty( cMsg )
     	addlog( "Processing error" )
     	oPopServer:Close()
     	SET CODEPAGE TO UNICODE
     	RETURN
ENDIF

//Add this line below
STRFILE (cMsg, "Message_" + n2c ( i ) + '.eml' )

(...)
edk
Posts: 909
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: save Outlook Attachment with "Umlaute"

Post by edk »

There is indeed something with the encoding of the attachment name.
I did a test of both variants: your RAW MIME

Code: Select all

U=CC=88berscha=CC=88tzung
and my RAW MIME

Code: Select all

=C3=9Cbersch=C3=A4tzung
In both cases they seem to be decoded into UTF8 the same (at least visually), but the string content itself is completely different.
You can also decode Quoted Printable both strings on this page https://www.webatic.com/quoted-printable-convertor
1.png
1.png (34.07 KiB) Viewed 1647 times
As a result of the decoding you will see the "same" result, but when you copy the result to a notepad as UTF-8 and then view the content through the Total Commander Viewer, the "umlaut" characters are displayed differently.
2.png
2.png (5.84 KiB) Viewed 1647 times
Also, watching the file in hex you can see the differences.
3.png
3.png (8.26 KiB) Viewed 1647 times
Converting to your OS codepage (probably DEWIN) is incorrect for your string, and OK for mine.

Code: Select all

set( _SET_CODEPAGE, "UTF8" )

t0  := "=?utf-8?Q?"
t99 := "?="
t1  := t0 + "U=CC=88berscha=CC=88tzung" + t99
t2  := t0 + "=C3=9Cbersch=C3=A4tzung" + t99
d1  := dekodujMIME( t1 )
d2  := dekodujMIME( t2 )
msginfo (t1 + crlf + d2)
msginfo (t2 + crlf + d2)

msgdebug (d1, d2, d1=d2 )

d1a := hb_Translate( d1, "UTF8", "DEWIN" )
d2a := hb_Translate( d2, "UTF8", "DEWIN" )

set( _SET_CODEPAGE, "DEWIN" )

msgdebug (d1a, d2a, d1a=d2a )
It looks like they are different UTF8 formats (although they are visually the same). This page http://www.mimastech.com/charset-detect ... -detector/ evaluates both strings as UTF-8.

I think after forwarding the message to me, the post-mail program converted the attachment name to a "correct" UTF8 Quoted Printable MIME. But how do you do it from the harbor level? I have no idea :cry:

I don't know what to do with it. :roll:
Post Reply