• 大小: 0.13M
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2024-04-30
  • 语言: C#
  • 标签:

资源简介


资源截图

代码片段和文件信息

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.Mail;

namespace Mlae
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        #region 邮箱核心代码
        //邮箱核心代码
        public void SendEmail()
        {
            try
            {
                MailMessage msg = new MailMessage();

                msg.To.Add(textBox1.Text.Trim());//收件人地址
                                                //msg.CC.Add(“cc@qq.com“);//抄送人地址  

                msg.From = new MailAddress(“*****“ “*****“);//发件人邮箱,名称  

                msg.Subject = textBox2.Text.Trim();//邮件标题
                msg.SubjectEncoding = Encoding.UTF8;//标题格式为UTF8  

                msg.Body = “收件Milae:  “ + textBox1.Text.Trim() + “\r\n“ + “主题:   “ + textBox2.Text.Trim() + “\r\n“ + “内容:   “ + textBox4.Text.Trim();//邮件内容
                msg.BodyEncoding = Encoding.UTF8;//内容格式为UTF8  
                if (textBox3.Text != ““)
                {
                    string sfile = textBox3.Text.Trim();//添加附件
                    msg.Attachments.Add(new Attachment(sfile));
                }

                SmtpClient client = new SmtpClient();

                client.Host = “smtp.qq.com“;//SMTP服务器地址
                client.Port = 587;//SMTP端口,QQ邮箱填写587  

                client.EnableSsl = true;//启用SSL加密  

                client.Credentials = new NetworkCredential(“****“ “*****“);//发件人邮箱账号,密码(此处为授权码)  

                client.Send(msg);//发送邮件  
                MessageBox.Show(“发送成功“ “系统提示“ MessageBoxButtons.OK MessageBoxIcon.Question);
            }
            catch (Exception ex)
            {
                MessageBox.Show(“Test“ ex.Message);
            }

        } 
        #endregion
        #region 添加附件
        //添加附件
        private void button6_Click(object sender EventArgs e)
        {

            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = “Excel文件(*.xls;*.xlsx)|*.xls;*.xlsx|所有文件|*.*“;
            ofd.ValidateNames = true;
            ofd.CheckPathExists = true;
            ofd.CheckFileExists = true;
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                string strFileName = ofd.FileName;
                textBox3.Text = strFileName;
                //其他代码
            }
        }
        #endregion
        #region 初始化系统
        private void Form1_Load(object sender EventArgs e)
        {

        } 
        #endregion
        #region 发送邮箱
        //发送邮箱
        private void button1_Click_1(object sender EventArgs e)
        {
            string Milae = textBox1.Text.Trim();//邮箱地址
            string user = textBox2.Text.Trim();//标题
            string fj = textBox3.Text.Trim();//对邮件主题进行编码
           

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

    ..A..H.     44032  2020-08-17 15:55  C#Mlae-发送邮箱 - 副本\.vs\Mlae\v16\.suo

     文件      11776  2020-08-17 15:55  C#Mlae-发送邮箱 - 副本\bin\Debug\Mlae.exe

     文件      34304  2020-08-17 15:55  C#Mlae-发送邮箱 - 副本\bin\Debug\Mlae.pdb

     文件       4359  2020-08-17 15:54  C#Mlae-发送邮箱 - 副本\Form1.cs

     文件       6857  2020-08-17 15:53  C#Mlae-发送邮箱 - 副本\Form1.Designer.cs

     文件       5817  2020-08-17 15:53  C#Mlae-发送邮箱 - 副本\Form1.resx

     文件       3412  2020-08-17 14:38  C#Mlae-发送邮箱 - 副本\Mlae.csproj

     文件       1112  2020-08-17 14:38  C#Mlae-发送邮箱 - 副本\Mlae.sln

     文件        208  2020-08-17 15:01  C#Mlae-发送邮箱 - 副本\obj\Debug\.NETframeworkVersion=v4.0.AssemblyAttributes.cs

     文件        424  2020-08-17 14:38  C#Mlae-发送邮箱 - 副本\obj\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       6857  2020-08-17 14:38  C#Mlae-发送邮箱 - 副本\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件         42  2020-08-17 15:01  C#Mlae-发送邮箱 - 副本\obj\Debug\Mlae.csproj.CoreCompileInputs.cache

     文件       1912  2020-08-17 15:55  C#Mlae-发送邮箱 - 副本\obj\Debug\Mlae.csproj.FileListAbsolute.txt

     文件       1012  2020-08-17 15:55  C#Mlae-发送邮箱 - 副本\obj\Debug\Mlae.csproj.GenerateResource.cache

     文件       2201  2020-08-17 15:55  C#Mlae-发送邮箱 - 副本\obj\Debug\Mlae.csprojAssemblyReference.cache

     文件      11776  2020-08-17 15:55  C#Mlae-发送邮箱 - 副本\obj\Debug\Mlae.exe

     文件        180  2020-08-17 15:55  C#Mlae-发送邮箱 - 副本\obj\Debug\Mlae.Form1.resources

     文件      34304  2020-08-17 15:55  C#Mlae-发送邮箱 - 副本\obj\Debug\Mlae.pdb

     文件        180  2020-08-17 14:38  C#Mlae-发送邮箱 - 副本\obj\Debug\Mlae.Properties.Resources.resources

     文件        485  2020-08-17 14:38  C#Mlae-发送邮箱 - 副本\Program.cs

     文件       1300  2020-08-17 14:38  C#Mlae-发送邮箱 - 副本\Properties\AssemblyInfo.cs

     文件       2821  2020-08-17 14:38  C#Mlae-发送邮箱 - 副本\Properties\Resources.Designer.cs

     文件       5612  2020-08-17 14:38  C#Mlae-发送邮箱 - 副本\Properties\Resources.resx

     文件       1091  2020-08-17 14:38  C#Mlae-发送邮箱 - 副本\Properties\Settings.Designer.cs

     文件        249  2020-08-17 14:38  C#Mlae-发送邮箱 - 副本\Properties\Settings.settings

     文件     106728  2020-08-17 15:49  C#Mlae-发送邮箱 - 副本\测试必看\密码(此处为授权码).png

     目录          0  2020-08-17 15:51  C#Mlae-发送邮箱 - 副本\.vs\Mlae\v16

     目录          0  2020-08-17 14:38  C#Mlae-发送邮箱 - 副本\obj\Debug\TempPE

     目录          0  2020-08-17 15:51  C#Mlae-发送邮箱 - 副本\.vs\Mlae

     目录          0  2020-08-17 15:51  C#Mlae-发送邮箱 - 副本\bin\Debug

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

评论

共有 条评论

相关资源