I have a system which periodically checks a mailbox for new items, and if there are any there downloads them, matches the subject line to a regex and processes them accordingly. I am using this to monitor daily report files and it works well when the file attached to an email is an excel / CSV file, however when the attachment is an HTML file it saves it completely garbled. The code I am using to save the email attachments is the same each time:
ArrayList attachments = new ArrayList();
if (email.NumAttachments > 0)
{
string SaveDir = string.Format("{0}{1}\\", ConfigurationManager.AppSettings["AttachmentDir"], Guid.NewGuid().ToString());
for (int a = 0; a < email.NumAttachments; a++)
{
attachments.Add(string.Format("{0}{1}", SaveDir, email.GetAttachmentFilename(a)));
email.SaveAttachedFile(a, SaveDir);
}
}
This is using the Chilkat email component, and as mentioned the problem only occurs when attempting to save an HTML attachment. I am monitoring a GMail mailbox if that makes any difference (shouldn't as I am just using POP3 to retrieve each time)
There is no recognisable text in the file - here is a sample if it is viewed in IE:
ä ¼äµ”ã¹Œà¨ä ¼ä……㹄à¨ä´¼å‘…â呈å”ä”啑噉∽潃瑮湥⵴祔数•佃呎久㵔ç¢ç¡¥â½´ç‘¨æ±æŒ»æ…¨ç²ç‘¥çœ½æ¹©æ½¤ç·ã„㔲∲ാ㰊䥔䱔㹅畣瑳ç¡ç°åˆ ç¥ç‰¯ã±´å¯å‘‰ä•Œà´¾ã°Šä ¯ä……㹄à¨äˆ¼ä‘ã¹™à¨å¼ä‰ä•Œäˆ å‰ä•„㵒‰䕃䱌å“ä义㵇‰䕃䱌ä…䑄义㵇‰ാ㰊剔ä 䥅䡇㵔㔵㸠à¨å¼â„䥗呄㵈㘵†ä±ä‰ãµŽä•Œå‘†ã¸ 㰠剂㰾å¯ã¹„å¼â„ä¥—å‘„ãµˆã¤´â€±ä„ ä¥Œä¹‡äŒ½ä¹…ä•”â’㰾㹂䘼ä¹â”瑳汹㵥但呎åŒå©‰ã©…ã˜³ç‘°ä˜ äãµ…å¢æµ©ç¥ä¸ ç¥åˆ 浯湡•佃佌㵒〣〰〰㸰慗敧ä ç¥¡ä„ ç™¤æ¹¡æ•£ã° ä˜¯ä¹ã¹”⼼㹂⼼䑔ാ㰊å¯ã¹’à¨â¼¼ä…”䱂㹅à¨å¼ä‰ä•Œäˆ å‰ä•„㵒‰䕃䱌å“ä义㵇‰䕃䱌ä…ä‘„ä¹
If I try and open in Textpad then characters outside of the latin charset are converted to system default