Microsoft.Legal.MatterCenter.Utility.MailMimeReader.ProcessHeaderField C# (CSharp) Method

ProcessHeaderField() private method

Convert one MIME header field and update message accordingly
private ProcessHeaderField ( MailMessageParser message, string headerField ) : void
message MailMessageParser Parsed message object
headerField string header field
return void
        private void ProcessHeaderField(MailMessageParser message, string headerField)
        {
            string headerLineType;
            string headerLineContent;
            int separatorPosition = headerField.IndexOf(ServiceConstants.COLON, StringComparison.CurrentCulture);
            if (0 < separatorPosition)
            {
                ////process header field type
                headerLineType = headerField.Substring(0, separatorPosition).ToUpperInvariant();
                headerLineContent = headerField.Substring(separatorPosition + 1).Trim(whiteSpaceChars);
                if (string.IsNullOrEmpty(headerLineType) || string.IsNullOrEmpty(headerLineContent))
                {
                    ////mail header parts missing, exist function
                    return;
                }
                //// add header line to headers
                message.Headers.Add(headerLineType, headerLineContent);

                switch (headerLineType)
                {
                    case ServiceConstants.MailAttributes.BCC:
                        AddMailAddresses(headerLineContent, message.Bcc);
                        break;
                    case ServiceConstants.MailAttributes.CC:
                        AddMailAddresses(headerLineContent, message.CC);
                        break;
                    case ServiceConstants.MailAttributes.CONTENT_DESCRIPTION:
                        message.ContentDescription = headerLineContent;
                        break;
                    case ServiceConstants.MailAttributes.CONTENT_DISPOSITION:
                        message.SetContentDisposition(headerLineContent);
                        break;
                    case ServiceConstants.MailAttributes.CONTENT_ID:
                        message.ContentId = headerLineContent;
                        break;
                    case ServiceConstants.MailAttributes.CONTENT_TRANSFER_ENCODING:
                        message.ContentTransferEncoding = ConvertToTransferEncoding(headerLineContent);
                        break;
                    case ServiceConstants.MailAttributes.CONTENT_TYPE:
                        message.SetContentTypeFields(headerLineContent);
                        break;
                    case ServiceConstants.MailAttributes.DATE:
                        message.DeliveryDate = this.ConvertToDateTime(headerLineContent);
                        break;
                    case ServiceConstants.MailAttributes.FROM:
                        MailAddress address = ConvertToMailAddress(headerLineContent);
                        if (null != address)
                        {
                            message.From = address;
                        }
                        break;
                    case ServiceConstants.MailAttributes.SENDER:
                        message.Sender = ConvertToMailAddress(headerLineContent);
                        break;
                    case ServiceConstants.MailAttributes.SUBJECT:
                        message.Subject = headerLineContent;
                        break;
                    case ServiceConstants.MailAttributes.TO:
                        AddMailAddresses(headerLineContent, message.To);
                        break;
                    case ServiceConstants.MailAttributes.IMPORTANCE:
                        message.MailImportance = headerLineContent;
                        break;
                    case ServiceConstants.MailAttributes.CATEGORIES:
                        message.MailCategories = headerLineContent;
                        break;
                    case ServiceConstants.MailAttributes.RECEIVED:
                        if (message.ReceivedDate.Year.Equals(1))
                        {
                            message.ReceivedDate = this.ProcessReceivedDate(headerLineContent);
                        }
                        break;
                    default:
                        message.UnknowHeaderlines.Add(headerField);
                        if (IsCollectHiddenHeaderLines)
                        {
                            AllHiddenHeaderLines.Add(headerField);
                        }

                        break;
                }
            }
        }
    }