Пример #1
0
        void DumpHeader(SocketExchange InEx, Int64 InMailDropPosition)
        {
            // dump the header lines of the top part.
            InEx.Logger.AddMessage(NetworkRole.Server, "--- start header line dump ---");
            MimeTopPart topPart = (MimeTopPart)mParts.GetTopPart();

            for (int Ix = 0; Ix < topPart.PropertyLines.Length; ++Ix)
            {
                InEx.Logger.AddMessage(NetworkRole.Server, topPart.PropertyLines[Ix]);
            }
            for (int Ix = 0; Ix < topPart.MessageLines.Length; ++Ix)
            {
                InEx.Logger.AddMessage(NetworkRole.Server, topPart.MessageLines[Ix]);
            }
            InEx.Logger.AddMessage(NetworkRole.Server, "--- end of header line dump ---");

            // dump the lines of each part.
            foreach (MimeMessagePart part in mParts)
            {
                InEx.Logger.AddMessage(NetworkRole.Server, "** message part **");
                InEx.Logger.AddMessage(NetworkRole.Server, "** property lines **");
                foreach (string line in part.PropertyLines)
                {
                    InEx.Logger.AddMessage(NetworkRole.Server, line);
                }
                InEx.Logger.AddMessage(NetworkRole.Server, "** message lines **");
                foreach (string line in part.MessageLines)
                {
                    InEx.Logger.AddMessage(NetworkRole.Server, line);
                }
            }
            InEx.Logger.AddMessage(NetworkRole.Server, "---- end of parts ----------");
        }
Пример #2
0
        // ----------------------- AddNewPart -------------------------------
        public MimeMessagePart AddNewPart(MimePartCode InPartCode)
        {
            MimeMessagePart part = null;

            if (InPartCode == MimePartCode.Top)
            {
                part = new MimeTopPart( );
            }
            else
            {
                part = new MimeMessagePart( );
            }

            part.PartCode = InPartCode;
            base.Add(part);

            return(part);
        }
Пример #3
0
        public MimeMessagePart AddNewPart(
            string InStream, MimeMessagePart.PartInProgress InPip)
        {
            MimeMessagePart part = null;

            if (InPip.PartCode == MimePartCode.Top)
            {
                part = new MimeTopPart( );
            }
            else
            {
                part = new MimeMessagePart( );
            }

            part.PartCode = InPip.PartCode;
            base.Add(part);

            // store the property lines of the part.
            if (InPip.PropBx != -1)
            {
                part.LoadPropertyLines(InStream, InPip.PropBx, InPip.PropLineCx);
            }

            // store the message lines of the part.
            if (InPip.MessageBx != -1)
            {
                part.LoadMessageLines(InStream, InPip.MessageBx, InPip.MessageLineCx);
            }

            // the message lines are quoted-printable encoded. decode here.
            if (AcCommon.StringValue(part.Properties.ContentTransferEncoding)
                == "quoted-printable")
            {
                part.DecodeMessageLines( );
            }

            return(part);
        }
Пример #4
0
        // ---------------------- LoadEmail ---------------------------
        private void LoadEmail(SocketExchange InEx, System.Int64 InMailDropPosition)
        {
            // tell the server we want to read the message.
            InEx.Send("retr " + InMailDropPosition + PopConstants.CrLf);

            InEx.ExpectedResponseCodes =
                new ExpectedResponseCodes(PopConstants.Ok, PopConstants.Error);
            InEx.SendReceive("retr " + InMailDropPosition + PopConstants.CrLf);
            InEx.ThrowIfUnexpectedResponse( );

            // -ERR response. no such message number.
            if (InEx.ResponseCode == PopConstants.Error)
            {
            }

            else
            {
                // for now, receive SSL link messages in the same thread.
                if (InEx.ConnectedSecureSocket != null)
                {
                    StringBuilder mail = null;
                    mail = ReceiveMessage_SameThread(InEx);
                    InEx.LoadResponseMessage(mail.ToString( ));
                }

                // receive in a background thread.
                else
                {
                    StartReceive(InEx);
                    InEx.LoadResponseMessage(mSockThreadState.sb.ToString( ));
                }
            }

            // parse email ...
            mParts = MimeCommon.MessagePartSplitter(InEx.ResponseMessage);

            string[] lines = MimeCommon.MessageLineSplitter(InEx.ResponseMessage);
            if (1 == 2)
            {
                mParts = MimeCommon.MessagePartSplitter(lines);
            }

            mAttachments = null;
            MimeAttachment attach = (MimeAttachment)Attachments.FirstAttachment( ).Current;

            if (attach != null)
            {
                attach.SaveAs("c:\\apress\\attachment.txt");
            }

            if (1 == 2)
            {
                // dump the header lines of the top part.
                InEx.Logger.AddMessage(NetworkRole.Server, "--- start header line dump ---");
                MimeTopPart topPart = ( MimeTopPart )mParts.GetTopPart( );
                for (int Ix = 0; Ix < topPart.PropertyLines.Length; ++Ix)
                {
                    InEx.Logger.AddMessage(NetworkRole.Server, topPart.PropertyLines[Ix]);
                }
                for (int Ix = 0; Ix < topPart.MessageLines.Length; ++Ix)
                {
                    InEx.Logger.AddMessage(NetworkRole.Server, topPart.MessageLines[Ix]);
                }
                InEx.Logger.AddMessage(NetworkRole.Server, "--- end of header line dump ---");

                // dump the lines of each part.
                foreach (MimeMessagePart part in mParts)
                {
                    InEx.Logger.AddMessage(NetworkRole.Server, "** message part **");
                    InEx.Logger.AddMessage(NetworkRole.Server, "** property lines **");
                    foreach (string line in part.PropertyLines)
                    {
                        InEx.Logger.AddMessage(NetworkRole.Server, line);
                    }
                    InEx.Logger.AddMessage(NetworkRole.Server, "** message lines **");
                    foreach (string line in part.MessageLines)
                    {
                        InEx.Logger.AddMessage(NetworkRole.Server, line);
                    }
                }
                InEx.Logger.AddMessage(NetworkRole.Server, "---- end of parts ----------");
            }

            for (int ix = 0; ix < lines.Length; ++ix)
            {
                InEx.Logger.AddMessage(NetworkRole.Server, lines[ix]);
            }
            ParseEmail(lines);

            // remove reading pop3State ...
            mSockThreadState = null;
        }