• 大小: 0.05M
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-02-27
  • 语言: C#
  • 标签: POP3  

资源简介

private void Connect_Click(object sender, System.EventArgs e)
        {
            //将光标置为等待状态
            Cursor cr = Cursor.Current;
            Cursor.Current = Cursors.WaitCursor;
            String a ,b,c; 
            //用110端口新建POP3服务器连接
            Server = new TcpClient(PopServer.Text, 110);
            Status.Items.Clear();

            try
            {
                //初始化
                NetStrm = Server.GetStream();
                RdStrm = new StreamReader(Server.GetStream());
                Status.Items.Add(RdStrm.ReadLine());

                //登录服务器过程
                Data = "USER " Username.Text CRLF;
                szData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray());
                NetStrm.Write(szData, 0, szData.Length);
                Status.Items.Add(RdStrm.ReadLine());

                Data = "PASS " Password.Text CRLF;
                szData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray());
                NetStrm.Write(szData, 0, szData.Length);
                Status.Items.Add(RdStrm.ReadLine());

                //向服务器发送STAT命令,从而取得邮箱的相关信息:邮件数量和大小
                Data = "STAT" CRLF;
                szData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray());
                NetStrm.Write(szData, 0, szData.Length);
                //Status.Items.Add(RdStrm.ReadLine());

                //改变按钮的状态
                Connect.Enabled = false;
                Disconnect.Enabled = true;
                Retrieve.Enabled = true;

                //将光标置回原来状态
                Cursor.Current = cr;

            }
            catch (InvalidOperationException err)
            {
                Status.Items.Add("Error: " err.ToString());
            }
        }

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using System.IO;

namespace MailReceiver
{
    /// 
    /// Form1 的摘要说明。
    /// 

    public partial class Form1 : System.Windows.Forms.Form
    {
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.Label label4;
        private System.Windows.Forms.Label label5;
        private System.Windows.Forms.Label label6;
        private System.Windows.Forms.TextBox PopServer;
        private System.Windows.Forms.TextBox Username;
        private System.Windows.Forms.TextBox Password;
        private System.Windows.Forms.RichTextBox Message;
        private System.Windows.Forms.TextBox Ma

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2014-10-31 22:01  Projejct1\
     目录           0  2014-10-31 22:40  Projejct1\Projejct1\
     文件        1197  2014-10-31 22:41  Projejct1\Projejct1\Form1.Designer.cs
     文件       30113  2014-11-02 11:13  Projejct1\Projejct1\Form1.cs
     文件        5817  2014-10-31 22:41  Projejct1\Projejct1\Form1.resx
     文件         494  2014-10-31 22:31  Projejct1\Projejct1\Program.cs
     文件        3677  2014-10-31 22:41  Projejct1\Projejct1\Projejct1.csproj
     目录           0  2014-10-31 22:01  Projejct1\Projejct1\Properties\
     文件        1350  2014-10-31 22:01  Projejct1\Projejct1\Properties\AssemblyInfo.cs
     文件        2870  2014-10-31 22:01  Projejct1\Projejct1\Properties\Resources.Designer.cs
     文件        5612  2014-10-31 22:01  Projejct1\Projejct1\Properties\Resources.resx
     文件        1096  2014-10-31 22:01  Projejct1\Projejct1\Properties\Settings.Designer.cs
     文件         249  2014-10-31 22:01  Projejct1\Projejct1\Properties\Settings.settings
     目录           0  2014-10-31 22:01  Projejct1\Projejct1\bin\
     目录           0  2014-11-02 11:22  Projejct1\Projejct1\bin\Debug\
     文件       16384  2014-11-02 11:22  Projejct1\Projejct1\bin\Debug\Projejct1.exe
     文件       24064  2014-11-02 11:22  Projejct1\Projejct1\bin\Debug\Projejct1.pdb
     文件       11600  2014-11-02 11:13  Projejct1\Projejct1\bin\Debug\Projejct1.vshost.exe
     文件         490  2010-03-17 22:39  Projejct1\Projejct1\bin\Debug\Projejct1.vshost.exe.manifest
     目录           0  2014-10-31 22:01  Projejct1\Projejct1\obj\
     目录           0  2014-10-31 22:01  Projejct1\Projejct1\obj\x86\
     目录           0  2014-11-02 11:22  Projejct1\Projejct1\obj\x86\Debug\
     文件        5359  2014-11-01 13:10  Projejct1\Projejct1\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache
     文件        6241  2014-11-02 11:22  Projejct1\Projejct1\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
     文件         180  2014-11-02 11:22  Projejct1\Projejct1\obj\x86\Debug\MailReceiver.Form1.resources
     文件         180  2014-11-02 11:22  Projejct1\Projejct1\obj\x86\Debug\Projejct1.Properties.Resources.resources
     文件         571  2014-11-02 11:22  Projejct1\Projejct1\obj\x86\Debug\Projejct1.csproj.FileListAbsolute.txt
     文件         975  2014-11-02 11:22  Projejct1\Projejct1\obj\x86\Debug\Projejct1.csproj.GenerateResource.Cache
     文件       16384  2014-11-02 11:22  Projejct1\Projejct1\obj\x86\Debug\Projejct1.exe
     文件       24064  2014-11-02 11:22  Projejct1\Projejct1\obj\x86\Debug\Projejct1.pdb
     目录           0  2014-11-02 11:23  Projejct1\Projejct1\obj\x86\Debug\TempPE\
............此处省略2个文件信息

评论

共有 条评论