• 大小: 56KB
    文件类型: .rar
    金币: 2
    下载: 1 次
    发布日期: 2021-06-13
  • 语言: C#
  • 标签: SMTP  邮件收发  C#  

资源简介

基于C#开发的邮件收发程序~适合在校学生使用

资源截图

代码片段和文件信息

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

namespace mailsend
{
    public partial class Form1 : Form
    {
        private TcpClient tcpClient;//TCP客户端        
        private StreamReader sr;//流读取器        
        private NetworkStream ns;//网络流        
        private string CRLF = “\r\n“;//特定的结束标记这个是RFC文档规定好的.        
        private string strData = string.Empty;//初始化数据段字符串
        public Form1()
        {
            InitializeComponent();
        }
        
        SmtpClient client = new SmtpClient();
        private void button_send_Click(object sender EventArgs e)
        {
            progressBar.Maximum = 100;
            try
            {
               
              
                client.Host = smtp_address.Text;
                progressBar.Value+=100/6;
                client.Credentials = new NetworkCredential(user.Text passw.Text);
                MailMessage mailMessage = new MailMessage();
                if(fujian.Text!=““)
                mailMessage.Attachments.Add(new Attachment(fujian.Text.Trim()));
                mailMessage.To.Add(acepter.Text);
                progressBar.Value += 100 / 6;
                mailMessage.From = new MailAddress(user.Textsender_name.Text);
                progressBar.Value += 100 / 6;
                mailMessage.Subject = zhuti.Text;
                progressBar.Value += 100 / 6;
                
                mailMessage.Body = mail_text.Text;
                progressBar.Value += 100 / 6;
                client.Send(mailMessage);
                progressBar.Value =100;
                MessageBox.Show(“邮件发送方成功!“);
            }
            catch(Exception ex)
            {   
                
                MessageBox.Show(ex.Message);
            }
        }
        private void SendInfo(string strCmd)      
        {             
                       
            strCmd += CRLF;  //CRLF表示结束符           
            byte[] data = Encoding.Default.GetBytes(strCmd);//网络中能够传输的都是byte数组所以需要转换.           
            ns.Write(data 0 data.Length);//网络流发送. 
            
        }
        private string AuthStream(string strCmd)    
        {           
            try           
            {               
                byte[] data = Encoding.Default.GetBytes(strCmd);                //转换成64位字符串格式                
                strCmd = Convert.Tobase64String(data);          
            }            
            catch(Exception ex)          
            {                return ex.Message;            }           
            
            return strCmd;
        }

        private void button_send2_Click(object sender EventArgs e)
        {
            progressBar.Maximum = 100;
           try      

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

     文件      16384  2010-04-18 13:23  mailsend\bin\Debug\mailsend.exe

     文件      32256  2010-04-18 13:23  mailsend\bin\Debug\mailsend.pdb

     文件      14328  2010-04-18 15:09  mailsend\bin\Debug\mailsend.vshost.exe

     文件        490  2007-07-21 02:33  mailsend\bin\Debug\mailsend.vshost.exe.manifest

     文件       8372  2010-04-18 13:23  mailsend\Form1.cs

     文件      14207  2010-04-18 13:23  mailsend\Form1.Designer.cs

     文件       6206  2010-04-18 13:23  mailsend\Form1.resx

     文件       3431  2010-04-14 18:33  mailsend\mailsend.csproj

     文件        905  2010-04-14 18:33  mailsend\mailsend.sln

    ..A..H.     16896  2010-04-18 15:17  mailsend\mailsend.suo

     文件       1858  2010-04-18 15:09  mailsend\obj\Debug\mailsend.csproj.FileListAbsolute.txt

     文件        847  2010-04-18 13:23  mailsend\obj\Debug\mailsend.csproj.GenerateResource.Cache

     文件      16384  2010-04-18 13:23  mailsend\obj\Debug\mailsend.exe

     文件        180  2010-04-18 13:23  mailsend\obj\Debug\mailsend.Form1.resources

     文件      32256  2010-04-18 13:23  mailsend\obj\Debug\mailsend.pdb

     文件        180  2010-04-14 18:43  mailsend\obj\Debug\mailsend.Properties.Resources.resources

     文件       4608  2010-04-14 18:34  mailsend\obj\Debug\TempPE\Properties.Resources.Designer.cs.dll

     文件        371  2010-04-14 17:07  mailsend\obj\mailsend.csproj.FileListAbsolute.txt

     文件        467  2010-04-14 16:27  mailsend\Program.cs

     文件       1200  2010-04-14 16:21  mailsend\Properties\AssemblyInfo.cs

     文件       2840  2010-04-14 18:33  mailsend\Properties\Resources.Designer.cs

     文件       5612  2010-04-14 16:21  mailsend\Properties\Resources.resx

     文件       1106  2010-04-14 18:33  mailsend\Properties\Settings.Designer.cs

     文件        249  2010-04-14 16:21  mailsend\Properties\Settings.settings

     文件        961  2010-04-14 18:33  mailsend\UpgradeLog.xml

     文件       3348  2010-04-14 18:33  mailsend\_UpgradeReport_Files\UpgradeReport.css

     文件      12505  2008-01-11 01:25  mailsend\_UpgradeReport_Files\UpgradeReport.xslt

     文件         69  2010-04-14 18:33  mailsend\_UpgradeReport_Files\UpgradeReport_Minus.gif

     文件         71  2010-04-14 18:33  mailsend\_UpgradeReport_Files\UpgradeReport_Plus.gif

     文件        148  2010-04-18 00:15  mailsend\参考网址.txt

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

评论

共有 条评论