aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes Mail attachment charset problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Mail attachment charset problem" Watch "Mail attachment charset problem" New topic
Author

Mail attachment charset problem

Jeppe Sommer
Ranch Hand

Joined: Jan 07, 2004
Posts: 270
Hello,

I have made a program which is able to send iCalendar files as an attachment. I get the data as an InputStream.

My problem is that the iCalendar file doesn�t show the letters '�', '�' and '�'. I have tried to use iso-8859-1 in the MimeBodyPart headerline and in the ByteArrayDataSource, but it doesn�t work?!

How do I specify which charset I want to use?

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18907
    
    8

When you say that the iCalendar file doesn't show those characters, exactly what does that mean?

Are you looking at the iCalendar file with a text editor or with an application that understands the iCalendar format?

Does it simply omit those characters, or does it actually replace them with something else? If so, what?
Jeppe Sommer
Ranch Hand

Joined: Jan 07, 2004
Posts: 270
Originally posted by Paul Clapham:
When you say that the iCalendar file doesn't show those characters, exactly what does that mean?

When I open the ICalendar file using a text editor these special letters are replaced, i.e.:

This is the original text:
This is the description text l�l�l�

- is replaced with:
DESCRIPTION;CHARSET=ISO-8859-1:This is the description text l?l?l?

and this original text:
The meeting name using the word m�de

- is replaced with:
SUMMARY;CHARSET=ISO-8859-1:The meeting name using the word m?de

Are you looking at the iCalendar file with a text editor or with an application that understands the iCalendar format?

Both. When open the Ical file with a text editor the letters isn�t shown correct. When open the file usin Outlook the letters isn�t shown correct.

Does it simply omit those characters, or does it actually replace them with something else? If so, what?

The letters are replaced with '?'

[ May 10, 2007: Message edited by: Jeppe Fjord ]
[ May 10, 2007: Message edited by: Jeppe Fjord ]
Jeppe Sommer
Ranch Hand

Joined: Jan 07, 2004
Posts: 270
I removed the line:
>mbp3.addHeaderLine("charset=iso-8859-1");

- and now the letters are shown correct when opening the ICalendar file using a text editor.

But when openning the file using Outlook the letters '�', '�', '�' are removed?! I know that isn�t a problem in my mail code but certainly in the iCal file?!
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18907
    
    8

For what it's worth, RFC2445 says this:
NON-US-ASCII = %x80-F8
; Use restricted by charset parameter
; on outer MIME object (UTF-8 preferred)
It also says this:
There is not a property parameter to declare the character set used
in a property value. The default character set for an iCalendar
object is UTF-8 as defined in [RFC 2279].
So it seems that the CHARSET part of "DESCRIPTION;CHARSET=ISO-8859-1:..." is not valid. But I would try using the UTF-8 encoding instead of ISO-8859-1.

If all else fails, use Outlook to generate an iCalendar file and see how it does it.
Jeppe Sommer
Ranch Hand

Joined: Jan 07, 2004
Posts: 270
Originally posted by Paul Clapham:
For what it's worth, RFC2445 says this: So it seems that the CHARSET part of "DESCRIPTION;CHARSET=ISO-8859-1:..." is not valid. But I would try using the UTF-8 encoding instead of ISO-8859-1.

If all else fails, use Outlook to generate an iCalendar file and see how it does it.


Alright so far so good... I removed the charset part ";CHARSET=ISO-8859-1:..." from my ICalendar file.

In my code I changed the code to use utf-8 (I also tried to remove the charset part):

The result is the same - the letters aren�t shown when opening the ICalender file using Outlook. So I saved an event file made by Outlook in the ICalendar format:

The original text:
M�de M�de m�de

- is shown like this saving the file with Outlook:
SUMMARY:M��de M��de m��de

I am confused?! I have read an article about some guys debating the same problem, but I don�t get the point how to solve it?!

http://www.dotnet247.com/247reference/msgs/43/217592.aspx
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Mail attachment charset problem