Code Monkey home page Code Monkey logo

Comments (1)

NiKiZe avatar NiKiZe commented on July 2, 2024

Subject lines are fixed, but still having issues with some attachments:
{"=?ISO-8859-1?Q?Invoice=5F509779.pdf?=", "Invoice_509779.pdf"} is shown correctly in Msg.Attachments[0].Name
But
{"faktura =?ISO-8859-1?Q?F14072-=F6stersund=2Epdf?=", "xxx"} is not.

The reason for this seems to be that the Name is handled in the Attachment implementation: http://www.dotnetframework.org/default.aspx/Dotnetfx_Win7_3@5@1/Dotnetfx_Win7_3@5@1/3@5@1/DEVDIV/depot/DevDiv/releases/whidbey/NetFXspW7/ndp/fx/src/Net/System/Net/Mail/Attachment@cs/1/Attachment@cs

        public string Name {
            get { 
                return name;
            } 
            set { 
                Encoding nameEncoding = MimeBasePart.DecodeEncoding(value);
                if(nameEncoding != null){ 
                    this.nameEncoding = nameEncoding;
                    this.name = MimeBasePart.DecodeHeaderValue(value);
                    MimePart.ContentType.Name = value;
                } 
                else{
                    this.name = value; 
                    SetContentTypeName(); 
                }
            } 
        }

internal class MimeBasePart 
    {
....
        internal static Encoding DecodeEncoding(string value) { 
            if(value == null || value.Length == 0){
                return null; 
            } 

            string[] subStrings = value.Split('?'); 
            if ((subStrings.Length != 5 || subStrings[0] != "=" || subStrings[4] != "=")) {
                return null;
            }
            string charSet = subStrings[1]; 
            return Encoding.GetEncoding(charSet);
        } 

If the filename starts with a valid encoded-word string then the name is automatically decoded and the encoding information is saved.

I will start using DecodeWords added if the name is taken from the name parameter.
But would like to get some input on possible issues with this solution.

            if (String.IsNullOrEmpty(name) && part.Parameters.ContainsKey("name"))
                name = Util.DecodeWords(part.Parameters["name"]);

Issue #28 might be related.

from s22.imap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.