Hi.
I have MIME e-mail message in multi-part format. It has an XML file attached:
------=_NextPart_000_007A_01C98582.2EB0A120
Content-Type: text/xml;
name="regform.xml"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="regform.xml"
<?xml version=3D"1.0" encoding=3D"UTF-8"?><?mso-infoPathSolution =
...
s1:Header><ns1:General><ns1:ent_full_name>=D0=9E=D0=B1=D1=89=D0=B5=D1=81=D1=
=82=D0=B2=D0=BE =D1=81 =
The source encoding of this file was UTF-8. Here you can see starting national (russian) characters wich 2-byte pairs are escaped by codes. I'm trying to extract attached XML file as byte[] data an save it to disk:
BusinessEntity[] attachments; |
activitymimeattachment currentAttachment; |
MimeEmailMessage mime; |
|
System.Diagnostics.EventLog eventLog = new System.Diagnostics.EventLog(); |
eventLog.Source = "MySource"; |
|
ServiceLogger serviceLogger; |
serviceLogger = new ServiceLogger(eventLog, LogLevel.Normal, "sl.log"); |
|
mime = new MimeEmailMessage(msgData, serviceLogger); |
attachments = mime.GetAttachments(); |
foreach (BusinessEntity be in attachments) |
{ |
byte[] data; |
|
currentAttachment = (activitymimeattachment)be; |
data = Convert.FromBase64String(currentAttachment.body); |
// FileName = ... |
using (FileStream fs = new FileStream(FileName, FileMode.Create)) |
{ |
fs.Write(data, 0, Data.Length); |
fs.Close(); |
} |
} |
When I open saved files I see that national characters are replaced by "?" and some other symbols. What I did wrong?