资源简介

C#语言的邮件收发系统,C#对网络编程的支持不太好,建议使用Java语言开发,该程序功能不是很强大,因此只建议学POP3和SMTP协议的新手看就行了。

资源截图

代码片段和文件信息

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;
using System.Collections;
using System.Data.OleDb;

namespace MailSendOfRecive
{
    public partial class Form1 : Form
    {
        TcpClient smtpSrv;
        NetworkStream netStm;
        string CRLF = “\r\n“;
        public List SMail = new List();
        public Form2 fa;
        public string Ua Pw Sv;
        public Form1(Form2 fstring UNstring Pdstring SR)
        {
            fa = f;
            Ua = UN;
            Pw = Pd;
            Sv = SR;
            InitializeComponent();
        }
        

        public void WriteStream(string strCmd)
        {
            strCmd += CRLF;   //crlf表示结束
            byte[] bw = System.Text.Encoding.Default.GetBytes(strCmd);  //将字符串转为字节数组
            netStm.Write(bw0bw.Length); //写入网络
        }
        private string AuthStream(string strCmd) //连接服务器输出字符串
        {
            try
            {
                byte[] by = System.Text.Encoding.Default.GetBytes(strCmd);
                strCmd = Convert.Tobase64String(by);  //转换成base64编码
            }
            catch (System.Exception ex)
            {
                return ex.ToString();
            }
            return strCmd;
        }
        public bool tryTran( ref string a)
        {
            string b = ““;
            b = a;
            try
            {
                byte[] outputb = Convert.Frombase64String(a);
                a = Encoding.Default.GetString(outputb);
                return true;
            }
            catch (System.Exception ex)
            {
                a= b;
                return false;
            }
        }
        public void WritInf(string s)
        {
            tryTran(ref s);
            listBoxMsg.Items.Add(s);

        }
        
        private void ButtonSend_Click(object sender EventArgs e)
        {
            
            listBoxMsg.Items.Clear(); //存放smtp服务器返回的信息
            //string SenIndo;
            try
            {
                string data;
                progressBar1.Visible = true;

                progressBar1.Value = 1;
                smtpSrv = new TcpClient(“smtp.“+Sv25);//TextBoxSer.Text25); //连接smtp服务器
                netStm = smtpSrv.GetStream(); //取得Networkstream对象来发送接收数据
                StreamReader rdStrm = new StreamReader(smtpSrv.GetStream());//产生StreamReader来读取数据流
                //SenIndo = “EHLO Local“; //+ TextBoxUser.Text;
                WriteStream(“EHLO Local“); //发送命令建立连接
                //string s = rdStrm.ReadLine();
                WritInf(rdStrm.ReadLine());
                WritInf(rdStrm.ReadLine());
                WritInf(rdStrm.ReadLine());
                WritInf(rdStrm.ReadLine())

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      27136  2013-10-11 10:22  MailSendOfRecive\MailSendOfRecive\bin\Debug\MailSendOfRecive.exe

     文件      54784  2013-10-11 10:22  MailSendOfRecive\MailSendOfRecive\bin\Debug\MailSendOfRecive.pdb

     文件      14328  2013-10-11 10:24  MailSendOfRecive\MailSendOfRecive\bin\Debug\MailSendOfRecive.vshost.exe

     文件        490  2009-06-11 05:14  MailSendOfRecive\MailSendOfRecive\bin\Debug\MailSendOfRecive.vshost.exe.manifest

     文件       7045  2013-05-28 03:41  MailSendOfRecive\MailSendOfRecive\Form1.cs

     文件       7964  2013-05-28 03:29  MailSendOfRecive\MailSendOfRecive\Form1.Designer.cs

     文件       5814  2013-05-28 03:29  MailSendOfRecive\MailSendOfRecive\Form1.resx

     文件      18881  2013-10-11 11:49  MailSendOfRecive\MailSendOfRecive\Form2.cs

     文件       9565  2013-10-10 16:09  MailSendOfRecive\MailSendOfRecive\Form2.Designer.cs

     文件       5814  2013-10-10 15:45  MailSendOfRecive\MailSendOfRecive\Form2.resx

     文件       2394  2013-05-28 00:58  MailSendOfRecive\MailSendOfRecive\Form3.cs

     文件       5166  2013-05-28 00:10  MailSendOfRecive\MailSendOfRecive\Form3.Designer.cs

     文件       5814  2013-05-28 00:10  MailSendOfRecive\MailSendOfRecive\Form3.resx

     文件       4351  2013-05-27 19:02  MailSendOfRecive\MailSendOfRecive\MailSendOfRecive.csproj

     文件       1259  2013-10-11 10:24  MailSendOfRecive\MailSendOfRecive\obj\Debug\MailSendOfRecive.csproj.FileListAbsolute.txt

     文件        963  2013-10-10 15:48  MailSendOfRecive\MailSendOfRecive\obj\Debug\MailSendOfRecive.csproj.GenerateResource.Cache

     文件      27136  2013-10-11 10:22  MailSendOfRecive\MailSendOfRecive\obj\Debug\MailSendOfRecive.exe

     文件        180  2013-09-17 15:25  MailSendOfRecive\MailSendOfRecive\obj\Debug\MailSendOfRecive.Form1.resources

     文件        180  2013-10-10 15:48  MailSendOfRecive\MailSendOfRecive\obj\Debug\MailSendOfRecive.Form2.resources

     文件        180  2013-09-17 15:25  MailSendOfRecive\MailSendOfRecive\obj\Debug\MailSendOfRecive.Form3.resources

     文件      54784  2013-10-11 10:22  MailSendOfRecive\MailSendOfRecive\obj\Debug\MailSendOfRecive.pdb

     文件        180  2013-09-17 15:25  MailSendOfRecive\MailSendOfRecive\obj\Debug\MailSendOfRecive.Properties.Resources.resources

     文件        497  2013-05-27 23:21  MailSendOfRecive\MailSendOfRecive\Program.cs

     文件       1394  2013-05-26 10:23  MailSendOfRecive\MailSendOfRecive\Properties\AssemblyInfo.cs

     文件       2882  2013-05-26 10:23  MailSendOfRecive\MailSendOfRecive\Properties\Resources.Designer.cs

     文件       5612  2013-05-26 10:23  MailSendOfRecive\MailSendOfRecive\Properties\Resources.resx

     文件       1101  2013-05-26 10:23  MailSendOfRecive\MailSendOfRecive\Properties\Settings.Designer.cs

     文件        249  2013-05-26 10:23  MailSendOfRecive\MailSendOfRecive\Properties\Settings.settings

     文件        938  2013-05-26 10:23  MailSendOfRecive\MailSendOfRecive.sln

    ..A..H.     25088  2013-10-11 11:49  MailSendOfRecive\MailSendOfRecive.suo

............此处省略12个文件信息

评论

共有 条评论