Exemple #1
0
        // ---------------------- LoadEmail ---------------------------
        private void LoadEmail(SocketExchange InEx, 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);

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

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

//      if (1 == 2)
//        DumpHeader(InEx, InMailDropPosition);

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

            // remove reading pop3State ...
            mSockThreadState = null;
        }
        // ---------------------- 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;
        }