Problem saving e-mail attachment with MS CRM 4.0 RRS feed

  • Question

  •  Hi.

    I have MIME e-mail message in multi-part format. It has an XML file attached:

    Content-Type: text/xml;
    Content-Transfer-Encoding: quoted-printable
    Content-Disposition: attachment;

    <?xml version=3D"1.0" encoding=3D"UTF-8"?><?mso-infoPathSolution =
    =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);      

    When I open saved files I see that national characters are replaced by "?" and some other symbols. What I did wrong?
    Tuesday, February 3, 2009 7:40 AM


  • Did you find an answer to this?  I find that XML files can be a problem--can't email them with Outlook and they can be hard to save as attachments.  One fix is to save as a .txt file.
    Monday, April 27, 2009 10:20 AM