资源简介

支持多发送

支持多抄送

支持附件

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;
using System.Net;

namespace SendEmail
{
    struct SendInfo
    {
        public string Name { get; set; }
        public string Url { get; set; }
        public string Pass { get; set; }
    }

    class EmailInfo
    {

        private List listrecipients;//收件人集合
        private List listsendduplicate;//抄送人集合

        private string recipients;//收件人
        private string sendduplicate;//抄送人
        private string context;//正文
        private string signature;//签名
        private string fileurl;//附件路径
        private string tittle;//标题

        public string Context { get { return context; } set { this.context = value; } }
        public string Signature { get { return signature; } set { this.signature = value; } }
        public string Recipients { get { return recipients; } set { this.recipients = value; } }
        public string SendDuplicate { get { return sendduplicate; } set { this.sendduplicate = value; } }
        public string FileUrl { get { return fileurl; } set { this.fileurl = value; } }
        public string Tittle { get { return tittle; } set { this.tittle = value; } }

        SmtpClient smtp;
        MailMessage mm;

        /// 
        /// 初始化
        /// 

        public bool init() 
        {
            //获取当前用户名密码名称
            SendInfo mysend=new SendInfo();
            mysend.Name= Properties.Settings.Default.MyName;
            mysend.Url = Properties.Settings.Default.MyUrl;
            mysend.Pass = Properties.Settings.Default.MyPass;

            string Stempurl = Properties.Settings.Default.SmtpUrl;  //StempUrl
            int StempPort = Properties.Settings.Default.SmtpPort;  //StempPort
            //设置收件人
            listrecipients = SetSendInfo(recipients);
            //设置抄送人
            listsendduplicate = SetSendInfo(sendduplicate);

            return SendEmail(mysend listrecipients listsendduplicate Stempurl StempPort);

        }

        public List SetSendInfo(string info)
        { 
            List ls=new List();
            string[] infos = info.Split(‘‘);
            foreach (var item in infos)
            {
                SendInfo si=new SendInfo();
                string[] ss= item.Split(‘<‘);
                if (ss.Length>1)
                {
                    si.Name = ss[0];
                    si.Url = ss[1].Substring(0 ss[1].Length - 1);
                }
                else
                {
                    si.Name = ss[0].Substring(1 ss[1].Length - 1);
                    si.Url = ss[0].Substring(1 ss[1].Length - 1);
                }
                ls.Add(si);  
            } 
            return ls; 
        }


        public bool SendEmail(SendInfo myinfoList smmList scc  string smtp_url in

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

     文件       2002  2020-12-30 16:35  SendEmail\app.config

     文件     325632  2017-08-02 01:07  SendEmail\bin\Debug\Newtonsoft.Json.Net35.dll

     文件      17408  2020-12-30 16:28  SendEmail\bin\Debug\SendEmail.exe

     文件       2018  2020-12-30 14:36  SendEmail\bin\Debug\SendEmail.exe.config

     文件      38400  2020-12-30 16:28  SendEmail\bin\Debug\SendEmail.pdb

     文件      14328  2020-12-30 16:29  SendEmail\bin\Debug\SendEmail.vshost.exe

     文件       2018  2020-12-30 14:36  SendEmail\bin\Debug\SendEmail.vshost.exe.config

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

     文件       5003  2020-12-30 16:36  SendEmail\EmailInfo.cs

     文件       3995  2020-12-30 16:34  SendEmail\Form1.cs

     文件       8940  2020-12-30 13:54  SendEmail\Form1.Designer.cs

     文件       5814  2020-12-30 13:54  SendEmail\Form1.resx

     文件       6569  2020-12-30 16:09  SendEmail\obj\Debug\ResolveAssemblyReference.cache

     文件        863  2020-12-30 16:29  SendEmail\obj\Debug\SendEmail.csproj.FileListAbsolute.txt

     文件        847  2020-12-30 16:09  SendEmail\obj\Debug\SendEmail.csproj.GenerateResource.Cache

     文件      17408  2020-12-30 16:28  SendEmail\obj\Debug\SendEmail.exe

     文件        180  2020-12-30 16:09  SendEmail\obj\Debug\SendEmail.Form1.resources

     文件      38400  2020-12-30 16:28  SendEmail\obj\Debug\SendEmail.pdb

     文件        180  2020-12-30 16:09  SendEmail\obj\Debug\SendEmail.Properties.Resources.resources

     文件        490  2020-12-30 08:53  SendEmail\Program.cs

     文件       1350  2020-12-30 08:53  SendEmail\Properties\AssemblyInfo.cs

     文件       2868  2020-12-30 08:53  SendEmail\Properties\Resources.Designer.cs

     文件       5612  2020-12-30 08:53  SendEmail\Properties\Resources.resx

     文件       3522  2020-12-30 16:35  SendEmail\Properties\Settings.Designer.cs

     文件       1108  2020-12-30 16:35  SendEmail\Properties\Settings.settings

     文件       3950  2020-12-30 13:59  SendEmail\SendEmail.csproj

     目录          0  2020-12-30 13:42  SendEmail\obj\Debug\Refactor

     目录          0  2020-12-30 08:53  SendEmail\obj\Debug\TempPE

     目录          0  2020-12-30 16:09  SendEmail\bin\Debug

     目录          0  2020-12-30 16:28  SendEmail\obj\Debug

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

评论

共有 条评论