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

资源简介

C#短信发送实现C#短信发送实现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.Mime;
using System.Net;
using System.IO;

namespace SendEmail
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            this.ImeMode = ImeMode.Hangul;
        }

        //窗体的Load事件
        private void Form1_Load(object sender EventArgs e)
        {
            //添加俩个smpt服务器的名称
            cmbBoxSMTP.Items.Add(“smtp.163.com“);
            cmbBoxSMTP.Items.Add(“smtp.gmail.com“);
            //设置为下拉列表
            cmbBoxSMTP.DropDownstyle = ComboBoxstyle.DropDownList;
            //默认选中第一个选项
            cmbBoxSMTP.SelectedIndex = 0;
            //在下面添加你想要初始化的内容,比如显示姓名、用户名等

        }

        //添加按钮的单击事件
        private void btnAdd_Click(object sender EventArgs e)
        {
            //定义并初始化一个OpenFileDialog类的对象
            OpenFileDialog openFile = new OpenFileDialog();
            openFile.InitialDirectory = Application.StartupPath;
            openFile.FileName = ““;
            openFile.RestoreDirectory = true;
            openFile.Multiselect = false;

            //显示打开文件对话框,并判断是否单击了确定按钮
            if (openFile.ShowDialog() == DialogResult.OK)
            {
                //得到选择的文件名
                string fileName = openFile.FileName;
                //将文件名添加到TreeView中
                treeViewFileList.Nodes.Add(fileName);
            }
        }

        //删除按钮的单击事件
        private void btnDelete_Click(object sender EventArgs e)
        {
            //判断是否选中了节点
            if (treeViewFileList.SelectedNode != null)
            {
                //得到选择的节点
                TreeNode tempNode = treeViewFileList.SelectedNode;
                //删除选中的节点
                treeViewFileList.Nodes.Remove(tempNode);
            }
            else
            {
                MessageBox.Show(“请选择要删除的附件。“);
            }
        }

        //发送按钮的单击事件
        private void btnSend_Click(object sender EventArgs e)
        {
            try
            {
                //确定smtp服务器地址。实例化一个Smtp客户端
                System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient(cmbBoxSMTP.Text);
                //生成一个发送地址
                string strFrom = string.Empty;
                if (cmbBoxSMTP.SelectedText == “smtp.163.com“)
                    strFrom = txtUserName.Text + “@163.com“;
                else
                    strFrom = txtUserName.Text + “@gmail.com“;

                //构造一个发件人地址对象
                MailAddress from = new MailAddress(strFrom txtDisplayName.Text Encoding.UTF8);
                //构造一个收件人地址对象
                MailAddress to = new MailAddress(txtEmail.Text txtToName.Text Encoding.UTF8);

                //构造一个Email的Message对象
                MailMessage mess

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

    .CA....     35053  2008-11-29 18:18  SendEmail\Image\AppLayout.JPG

    .CA....     42113  2008-11-29 20:01  SendEmail\Image\AppRun1.JPG

    .CA....     42309  2008-11-29 20:02  SendEmail\Image\AppRun2.JPG

    .CA....     41595  2008-11-29 20:05  SendEmail\Image\Email.JPG

    .CA....     28672  2008-11-29 19:59  SendEmail\SendEmail\bin\Debug\SendEmail.exe

    .CA....     28160  2008-11-29 19:59  SendEmail\SendEmail\bin\Debug\SendEmail.pdb

    .CA....      5632  2005-11-11 22:25  SendEmail\SendEmail\bin\Debug\SendEmail.vshost.exe

    .CA....      5909  2008-11-29 19:59  SendEmail\SendEmail\Form1.cs

    .CA....     15773  2008-11-29 19:09  SendEmail\SendEmail\Form1.Designer.cs

    .CA....      5814  2008-11-29 19:09  SendEmail\SendEmail\Form1.resx

    .CA....       842  2008-11-29 19:16  SendEmail\SendEmail\obj\Debug\SendEmail.csproj.GenerateResource.Cache

    .CA....     28672  2008-11-29 19:59  SendEmail\SendEmail\obj\Debug\SendEmail.exe

    .CA....       180  2008-11-29 19:16  SendEmail\SendEmail\obj\Debug\SendEmail.Form1.resources

    .CA....     28160  2008-11-29 19:59  SendEmail\SendEmail\obj\Debug\SendEmail.pdb

    .CA....       180  2008-11-29 17:54  SendEmail\SendEmail\obj\Debug\SendEmail.Properties.Resources.resources

    .CA....       282  2008-11-30 08:32  SendEmail\SendEmail\obj\SendEmail.csproj.FileList.txt

    .CA....       468  2008-11-29 17:53  SendEmail\SendEmail\Program.cs

    .CA....      1172  2008-11-29 17:53  SendEmail\SendEmail\Properties\AssemblyInfo.cs

    .CA....      2873  2008-11-29 17:53  SendEmail\SendEmail\Properties\Resources.Designer.cs

    .CA....      5612  2008-11-29 17:53  SendEmail\SendEmail\Properties\Resources.resx

    .CA....      1093  2008-11-29 17:53  SendEmail\SendEmail\Properties\Settings.Designer.cs

    .CA....       249  2008-11-29 17:53  SendEmail\SendEmail\Properties\Settings.settings

    .CA....      3225  2008-11-29 17:54  SendEmail\SendEmail\SendEmail.csproj

    .CA....       916  2008-11-29 17:53  SendEmail\SendEmail.sln

    .CA..H.     12800  2008-11-29 20:32  SendEmail\SendEmail.suo

    .C.D...         0  2008-11-29 18:51  SendEmail\SendEmail\obj\Debug\Refactor

    .C.D...         0  2008-11-29 17:53  SendEmail\SendEmail\obj\Debug\TempPE

    .C.D...         0  2008-11-29 17:54  SendEmail\SendEmail\bin\Debug

    .C.D...         0  2008-11-29 19:59  SendEmail\SendEmail\obj\Debug

    .C.D...         0  2008-11-29 17:53  SendEmail\SendEmail\bin

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

评论

共有 条评论