Vi riporto questa discussione:
" Dear All,
there is a method to get the charset of a mimepart
( eg. part.ContentType = "plain/text" ) ?
Best Regards
Roberto "
" I use this code in the EMail function to set the mime. I'm not very sure if
this is what you are asking for:
For Each fich In aAttached
Exec ["file", "-bi", fich] To mime
mime = Left(mime, InStr(mime, ";") - 1)
fname = Right(fich, - RInStr(fich, "/"))
SmtpC.Add(File.Load(fich), mime, fname)
Next
Hope this helps.
Regards
Jorge "
" Thanks Jorge for you fast reply
I have tried with:
s = hPart.Headers["content-type"]
If InStr(s, "charset") > 0 Then
bla bla bla (estrapolate "charset" content )
endif
but is not an excellent solution
Roberto "
" AFAIK, the only place where the charset is specified is in the "charset"
part of the Content-Type header (that you can get with the hPart.ContentType property directly).
If the charset is not specified, I guess that you must guess!
Regards,
--
Benoît Minisini "
...continua...
" Hi Benoît (it is always a pleasure to read you in mailing list)
we have eg 3 cases:
1°->
"Content-Type: text/plain; charset="iso-8859-1"
print hpart.ContentType
output-> "text/plain"
print hpart.Header["Content-type"]
output-> text/plain; charset="iso-8859-1"
2°->
"Content-Type: text/plain; charset=windows-1252; format=flowed"
print hpart.ContentType
output-> "text/plain"
print hpart.Header["Content-type"]
output-> "text/plain; charset=windows-1252; format=flowed"
3°->
->Content-Type: text/plain;
charset="UTF-8" <-
print hpart.ContentType
output-> "text/plain"
print hpart.Header["Content-type"]
output-> text/plain; charset="UTF-8"
I found the following solution that seems to work, waiting for your
review with the possibility of using hpart.charset
s = hPart.Headers["content-type"]
If InStr(s, "charset") > 0 Then
s = Mid(s, InStr(s, "charset=") + 8)
s = Left(s, InStr(s & " ", " "))
s = Replace(s, ";", "")
s = Trim(Replace(s, Chr(34), ""))
Try s = Conv(hPart.Data, s, "utf-8")
If Error Then Message.Error("errore nel decodificare una parte mime " & Error.text, "ok")
Return
Else
Return hpart.Data
Endif
Regards
Roberto "
" I didn't realize that the charset was stripped by the ContentType
property, because this property is a direct interface to the gmime library.
Maybe I will add a "Charset" method that extract the optional charset
part for you.
Regards,
--
Benoît Minisini "