Mail Attachment Names contains Question Marks instead of umlauts

Hi,

I have a Problem.

I want to load a MSG Email File into MapiMessage to extract the Attachments to the disk.

Here is the code:

MapiMessage email = MapiMessage.FromFile("c:\\temp\\Emailkategorisierung\\Emails\\" + datei.Name);

Aspose.Network.Outlook.MapiAttachmentCollection meineanlagen = email.Attachments;

string Anlagennamen = "";

for (int i = 0; i < meineanlagen.Count; i++)

{

meineanlagen[i].Save("c:\\temp\\Emailkategorisierung\\Emailanlagen\\" + meineanlagen[i].LongFileName);

}

So I can't save Emails with Umlaut(ä,ü,ß,ö,...) because instead of this characters, there will shown question marks ("?") and so there's a exception that I can't save the File because in the Filename there is a "?".

Then I decided to load the MSG Mail into a MailMessage Class, but there are all attachments away, only 1 attachement called licenses.txt is in it (I think because the evaluation version).

In the Attachment there's a Testmail. I need quickly a solution please.

Thanks for your help

Hi,

Thanks for considering Aspose.

Please try the latest hotfix from http://www.aspose.com/community/files/51/file-format-components/aspose.network-for-.net/entry179958.aspx.

If you still encounter problem after using the above dll, please mention your environment, e.g. Operating System (x86/x64) and .NET framework version. We will do the tests in similar environment to analyze the problem.

Hi,

the same problem again.

In the attachments of this post you see a screenshot, that the attachment names of the email with ä,ü,ö,ß contains question marks (?) instead of this characters.

I develop on a x86 windows server 2003 with .net framework 3.5 inclusive .net framework 3.5 SP1

Can you help me please?

Thanks a lot

Hi,
Maybe this could be a solution for you. I tested it with umlauts and it works.

MailMessage mailMessage = MailMessage.Load(txtInputTemplate.Text, MessageFormat.Msg);
mailMessage.BodyEncoding = Encoding.Unicode;
foreach (Attachment attachment in mailMessage.Attachments)
{
attachment.NameEncoding = Encoding.Unicode;
attachment.Save(“c:\temp\” + attachment.Name);
}





Regards
Swisscomdev

Hi,

thank's a lot for your code, but the problem is this.

I have the evaluation version of aspose network because we want to decide if we will buy this library. If I use the MailMessage class instead of MapiMessage, the attachments of the email will not be shown, only 1 attachment (license.txt) will be display and so I can't test it with my umlauts...

can anyone of the support team help me

Hi,

Thanks for considering Aspose.

Could you please run the attached sample application on your system?

The executable folder contains the exe and Aspose.Network.dll file. It will open the dialog box for opening the file and will show the filename on the screen. It worked in my environment here (Windows 2003 Server x86 and .NET 2.0/3.5 sp1). Please test whether it works for you.

I can’t see a attached file on your post??

Hi,

Sorry, I forgot to attach the files. Please download from this post.

Hello again,

your test program works with ä,ö etc in the attachment names using mapimessage. using the mailmessage class there will only shown "License.txt", because of the evaluation version i think.

why doesn't work this in my program with this characters?What have you done instead of my code??

Thanks for your help

Hello,

Could you help to try the latest hotfix? It is fixed in the latest dll. I have tested with your code and MailMessage class.

MailMessage msg = MailMessage.Load(file, MessageFormat.Msg);
for (int i = 0; i < msg.Attachments.Count; i++)
{
msg.Attachments[i].Save(msg.Attachments[i].Name);
}
msg.Save("Msg_AttachmentLoadIssue_20090525_Test.eml");

http://www.aspose.com/community/files/51/file-format-components/aspose.network-for-.net/entry179958.aspx

Thanks,

I tried this hotfix, but this didn't solve the problem...

With your test solution I open the Testmail an den characters will shown correctly, but if I use it on my solution, there are always question marks instead of ö,ü,...

I don't know what's the different between your solution... I have a ClassLibrary Project and you have a Forms Application but this can't be the reason...

Can I do something else?

Look at my screenshot... here you can see that I use exactly the same code as in your forms application... and of course the same Aspose Library (from your folder)....

The email is exactly the same as the mail which I used for testing it with your forms application

Hi,

Could you please try the Aspose.Network.dll, that is included in my sample (attached to the previous post). See if you still get the question marks instead of correct characters.

Yes I tested this hotfix but without any success...

I don't understand why it works in the form application and not in my library.

Here my scenario:

We use Microsoft Sharepoint. I upload outlook emails to a Sharepoint Library, then a eventhandler save this email back to C:\Temp and then I try to read the attachments with the MapiMessage, that's all what I do.

I develop with Visual Studio 2008, Windows Server 2003, .NET Framework 3.5

The mistake must be on another side, because the DLL works I think, because with the form test application from you it works. Have you tried it with a non-form application (only a library or console or something like that)?

We have to find a solution for that, because we are very intereseted in buying this Library but we need to solve this problem first.

I will do some tests with other project types (non-winform applications) and a similar scenario like yours (create a dll and read the msg file from SharePoint document library) and will post my findings here shortly.

okay fine thank you, I hope you can find the same problem as I have and find a solution for that

are there new information?

what’s on?? can you solve this problem or not?

Hi,

Sorry for replying late.

I tested with console and dll project types, but there were no issues. Attachments were being saved correctly including the special characters.

I just tested with SharePoint too by uploading the file to the document library and accessing using MailMessage.Load(stream) method, but again no issues.

Could you please make sure that the dll that is being referenced in your project is exactly same as I sent you earlier. I would recommend to delete the reference and add again the dll from my folder.

Most probably, it seems the dll version issue, because I have tested on 32/64 bit and .net 2.0/3.5 frameworks, but no issues found.

Hi,

thanks for your reply. I don’t think, that’s the problem is the DLL file.

In the ViewMsg Solution of you, I tested the Email with special characters in the attachments name with an email which I drag out from outlook to the desktop.

This works fine with the characters.

If I try to load the email, which I have saved with the code below, the characters won’t be displayed as I want (same problem as I explained):

Here is the Code:

SPFile datei = properties.ListItem.File;

byte[] fileBuffer = datei.OpenBinary();

string path = “c:\temp\Emailkategorisierung\Emails\” + datei.Name;

FileStream stream = new FileStream(path, FileMode.Create);

stream.Write(fileBuffer, 0, fileBuffer.Length);

stream.Close();

MapiMessage email = MapiMessage.FromFile(“c:\temp\Emailkategorisierung\Emails\” + datei.Name);

This MapiMessage don’t work with the characters. You told me, that you have tested it with a class library with Sharepoint.

Can you please post your code, how you have load the file to the MapiMessage from Sharepoint?

I think this could solve my problem. I think the problem is anywhere in Sharepoint or how Sharepoint save the emails, I’m not sure.

Thanks a lot

UPDATE

I have tested following secaniro:

I uploaded a email with sharepoint (Upload file - choose file - click upload and then the file is in the sharepoint) and after that I downloaded this email again (rigt click - save as) and then try to read the attachments with the ViewMsg solution.

THIS WORKS!!!

When I upload a Email from Outlook to Sharepoint programmatically (Outlook Addin in C#, a simply save as function) then the attachment names won’t be display correct (but only in the aspose mailmessage/mapimessage). If I open this email with outlook, there’s no problem or something else.

Same problem if I open any email in outlook, go to File - Save As - http://sharepoint/docbib/test.msg and download this file back to desktop and test it with view msg. So the problem isn’t from my outlook addin, the problem must be on your class library or outlook?!?

Can you check how you load the attachment namens in the mapimessage class? maybe there is another way ??