Search code examples
exceptionmedia-typeopenpopemail-parsing

While parsing email Getting exception "Media Type must be in the format type "/" subtype Parameter name: mediaType"


My project parse email through OpenPop library. Every time mail from specific sender is not parsing and getting following exception

Message: Media Type must be in the format type "/" subtype Parameter name: mediaType Source: OpenPop TargetSite: System.String cleanMediaType(System.String) StackTrace: at OpenPop.Mime.Header.HeaderFieldParser.cleanMediaType(String mediaType) at OpenPop.Mime.Header.HeaderFieldParser.ParseContentType(String headerValue) at OpenPop.Mime.Header.MessageHeader.ParseHeader(String headerName, String headerValue) at OpenPop.Mime.Header.MessageHeader.ParseHeaders(NameValueCollection headers) at OpenPop.Mime.Header.MessageHeader..ctor(NameValueCollection headers, IParsingErrorHandler parsingErrorHandler) at OpenPop.Mime.Header.HeaderExtractor.ExtractHeadersAndBody(Byte[] fullRawMessage, MessageHeader& headers, Byte[]& body, IParsingErrorHandler parsingErrorHandler) at OpenPop.Mime.MessagePart.ParseMultiPartBody(Byte[] rawBody) at OpenPop.Mime.MessagePart.ParseBody(Byte[] rawBody) at OpenPop.Mime.MessagePart..ctor(Byte[] rawBody, MessageHeader headers, IParsingErrorHandler parsingErrorHandler) at

Openpop code is here

Exception throws from following class enter image description here

Question is

How can I handle this exception?

Or Is there any New version of OpenPop with this fix?


Solution

  • Question is

    How can I handle this exception?

    • Handling exception deos not needful, because I want to parse and download email. so I need to change code of OpenPop.dll's code.I downloaded code and with little bit of changes I am able to parse email

    enter image description here

    Or Is there any New version of OpenPop with this fix?

    • No I am using latest version.