• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Mail类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Mail的典型用法代码示例。如果您正苦于以下问题:C# Mail类的具体用法?C# Mail怎么用?C# Mail使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Mail类属于命名空间,在下文中一共展示了Mail类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: btnSubmit_Click

    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (!Page.IsValid) return;
        int receiverID=(int)ViewState["receiverID"];
        using (MooDB db = new MooDB())
        {
            Mail mail=new Mail()
            {
                From = ((SiteUser)User.Identity).GetDBUser(db),
                To = (from u in db.Users
                      where u.ID == receiverID
                      select u).Single<User>(),
                Title = txtTitle.Text,
                Content = txtContent.Text,
                IsRead = false,
            };

            db.Mails.AddObject(mail);

            db.SaveChanges();

            Logger.Info(db,string.Format("向用户#{0}发送邮件#{1}",receiverID,mail.ID));
        }

        PageUtil.Redirect("创建成功", "~/Mail/List.aspx");
    }
开发者ID:MooDevTeam,项目名称:MooOJ,代码行数:26,代码来源:Create.aspx.cs


示例2: SubmitBtn_Click

    protected void SubmitBtn_Click(object sender, EventArgs e)
    {
        AccessDB dbObj = new AccessDB();
        dbObj.Open();
        dbObj.Query = string.Format("Select emailaddress,CAST( AES_DECRYPT( passwd, 'kalli' ) AS CHAR( 100 ) ) from tbluserlogin where emailaddress ='{1}'", Constants.AESKey, UserNameTbx.Text);
        dbObj.ExecuteQuery();

        if (dbObj.Dataset.Tables[0].Rows.Count > 0)
        {
            Mail mailObj = new Mail();
            mailObj.To = UserNameTbx.Text;
            mailObj.Subject = "Reply: Forgot Password Request";
            mailObj.MailBody = string.Format("Dear Ma'am/Sir, \r\n Username:{0} \r\n Password:{1} \r\n Regards, \r\n Admin team.", UserNameTbx.Text, dbObj.Dataset.Tables[0].Rows[0][1]);
            mailObj.SendMailMessage();

            VerificationLbl.Text = "Your password has been sent to your email.";
            VerificationLbl.Visible = true;
        }
        else
        {
            VerificationLbl.Text = "The UserName provided is not valid.Kindly verify and retry / contact the Admin Team.";
            VerificationLbl.Visible = true;
        }
        dbObj.Close();
    }
开发者ID:Kallivayalil,项目名称:Kallivayalil,代码行数:25,代码来源:ForgotPassword.aspx.cs


示例3: createComentario

        public Mensaje createComentario([FromBody]UtilsJson.AContacto comentario)
        {
            Mensaje mensaje = null;

            try
            {
                //datos logueo
                string nombre = comentario.nombre_contacto;
                string telefono = comentario.telefono_contacto;
                string email = comentario.email_contacto;
                string messangeC = comentario.comentario_contacto;

                Contacto contacto = new Contacto(nombre, telefono, email, messangeC);
                contacto.fecha_ult_modificacion = DateTime.Now;
                _repositorio.SaveOrUpdate(contacto);
                //Envio email confirmacion para habilitar el perfil
                StringBuilder bodyMail = new StringBuilder();
                bodyMail.AppendLine("Comentario enviado por: " + nombre);
                bodyMail.AppendLine("Telefono: " + telefono);
                bodyMail.Append(comentario);
                string subject = "Comentario o sugerencia. " + email;
                Mail mail = new Mail("[email protected]", subject, bodyMail);
                mail.sendMail();
                mensaje = new Mensaje(EnumTipoMensaje.Notificacion, "Notificación", "Comentario procesado exitosamente.");
            }
            catch (Exception ex)
            {
                mensaje = new Mensaje(EnumTipoMensaje.Error, "Error", "Ocurrio un error mientras se procesaba su solicitud.");
            }
            return mensaje;
        }
开发者ID:davide162,项目名称:BTR_SERVICES,代码行数:31,代码来源:ContactoController.cs


示例4: SaveRead_Test

        public void SaveRead_Test()
        {
            var mail = new Mail(logger);
            var mlName = "1ban";
            MlDb mlDb = new MlDb(logger, dir,mlName);
            mlDb.Remove();//もし、以前のメールが残っていたらTESTが誤動作するので、ここで消しておく

            Assert.AreEqual(mlDb.Count(), 0);

            var max = 10;//試験件数10件
            //保存と、
            for (int i = 0; i < max; i++) {
                var b = mlDb.Save( mail);
                Assert.AreEqual(b,true);//保存が成功しているか
                Assert.AreEqual(mlDb.Count(), i+1);//連番がインクリメントしているか
            }
            //範囲外のメール取得でnullが返るか
            //no==1..10が取得可能
            var m = mlDb.Read(0);//範囲外
            Assert.IsNull(m);
            //範囲内
            for (int no = 1; no <= max; no++) {
                m = mlDb.Read(no);
                Assert.NotNull(mlDb.Read(no));
            }
            //範囲外
            m = mlDb.Read(11);
            Assert.IsNull(m);

            mlDb.Remove();
        }
开发者ID:jsakamoto,项目名称:bjd5,代码行数:31,代码来源:MlDbTest.cs


示例5: SendAsync

        public async Task SendAsync(IdentityMessage message)
        {
            //var myMessage = new SendGridMessage();
            //myMessage.AddTo(message.Destination);
            //myMessage.From = new MailAddress("[email protected]", "fzrain");
            //myMessage.Subject = message.Subject;
            //myMessage.Text = message.Body;
            //myMessage.Html = message.Body;

            //var credentials = new NetworkCredential("fzy55601", "fzy86087108");
            //// Create a Web transport for sending email.
            //var transportWeb = new Web(credentials);
            //// Send the email.
            //await transportWeb.DeliverAsync(myMessage);

            String apiKey = Environment.GetEnvironmentVariable("NAME_OF_THE_ENVIRONMENT_VARIABLE_FOR_YOUR_SENDGRID_KEY", EnvironmentVariableTarget.User);
            dynamic sg = new SendGridAPIClient(apiKey);

            Email from = new Email("[email protected]");
            String subject = "Hello World from the SendGrid CSharp Library";
            Email to = new Email("[email protected]");
            Content content = new Content("text/plain", "Textual content");
            Mail mail = new Mail(from, subject, to, content);

            dynamic response = sg.client.mail.send.post(requestBody: mail.Get());
        }
开发者ID:fzrain,项目名称:Material-Design-AngularJs-Abp,代码行数:26,代码来源:EmailService.cs


示例6: Index

        public IActionResult Index(Mail Data)
        {
            if (ModelState.IsValid)
            {
                StringBuilder message = new StringBuilder();
                MailAddress from = new MailAddress(Data.Email);
                message.Append("Name: " + Data.Name + "\n");
                message.Append("Email: " + Data.Email + "\n");
                message.Append("Subject: " + Data.Subject + "\n");
                message.Append("Subject: \n" + Data.Message);

                MailMessage mail = new MailMessage();

                SmtpClient smtp = new SmtpClient();

                smtp.Host = "smtp.gmail.com";
                smtp.Port = 587;
                smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
                smtp.UseDefaultCredentials = false;

                smtp.Credentials = new System.Net.NetworkCredential("[email protected]", "K33ls3n2188#");
                smtp.EnableSsl = true;

                mail.From = from;
                mail.To.Add("[email protected]");
                mail.Subject = "Keelsen Contact Form: " + Data.Subject + " (" + Data.Email + ")";
                mail.Body = message.ToString();

                smtp.Send(mail);
                Data.Done = true;
            }
            return View(Data);

        }
开发者ID:worldvibe,项目名称:keelsen,代码行数:34,代码来源:HomeController.cs


示例7: SubmitBtn_Click

    protected void SubmitBtn_Click(object sender, ImageClickEventArgs e)
    {
        Mail mailObj = new Mail();
        mailObj.MailBody = CommentTB.Text;

        //Will by default have the from address as '[email protected]'
        mailObj.From = Session["UserLogin"].ToString();

        mailObj.Subject = string.Format("{0}:{1}", Session["UserLogin"].ToString(), ReasonDDL.SelectedValue);
        mailObj.To = ConfigurationManager.AppSettings["AdminEmail"];
        mailObj.SendMailMessage();

        #region mailToAllAdmins
        //Send to all Admins ..
        //      AccessDB dbObj = new AccessDB();
        //      dbObj.Open();

        /*dbObj.Dataset.Reset();
        dbObj.Query = string.Format(@"Select emailaddress from tbluserlogin where isadmin=true");
        dbObj.ExecuteQuery();

        for (int i = 0; i < dbObj.Dataset.Tables[0].Rows.Count; i++)
        {
            mailObj.To = dbObj.Dataset.Tables[0].Rows[i][0].ToString();
            mailObj.SendMailMessage();
        }*/
        #endregion

        ConfMsgLbl.Visible = true;
    }
开发者ID:Kallivayalil,项目名称:Kallivayalil,代码行数:30,代码来源:ContactUs.aspx.cs


示例8: GetEmailBody

        public static string GetEmailBody(Mail emailName, object model)
        {
            var templatePath = physicalApplicationPath + @"Views\EmailTemplates\" + emailName + ".cshtml";
            var template = System.IO.File.ReadAllText(templatePath, System.Text.Encoding.Default);

            return Razor.Parse(template, model);
        }
开发者ID:salemano,项目名称:ConferenceApp,代码行数:7,代码来源:Helper.cs


示例9: DoBuildAndSendMail

 // tag::buildAndSendMail[]
 public void DoBuildAndSendMail(MailMan m, MailAddress mAddress,
     MailBody mBody) {
     // Build the mail
     Mail mail = new Mail(mAddress, mBody);
     // Send the mail
     m.SendMail(mail);
 }
开发者ID:ishara,项目名称:building_maintainable_software,代码行数:8,代码来源:BuildAndSendMail.cs


示例10: Send

        public static void Send(Mail mail)
        {
            MailMessage msg = new MailMessage();
            msg.From = new MailAddress(mail.From, "Money Pacific Service");
            msg.To.Add(new MailAddress(mail.To));
            msg.Subject = mail.Subject;
            msg.Body = mail.Body;

            msg.IsBodyHtml = true;
            msg.BodyEncoding = new System.Text.UTF8Encoding();
            msg.Priority = MailPriority.High;

            SmtpClient smtp = new SmtpClient();
            smtp.Host = "smtp.gmail.com";
            System.Net.NetworkCredential user = new
                System.Net.NetworkCredential(
                    ConfigurationManager.AppSettings["sender"],
                    ConfigurationManager.AppSettings["senderPass"]
                    );

            smtp.EnableSsl = true;
            smtp.Credentials = user;
            smtp.Port = 587; //or use 465 
            object userState = msg;

            try
            {
                //you can also call client.Send(msg)
                smtp.SendAsync(msg, userState);
            }
            catch (SmtpException)
            {
                //Catch errors...
            }
        }
开发者ID:vramsngrai1994,项目名称:mkpacific-ltd,代码行数:35,代码来源:MPMail.cs


示例11: Create

        public object Create(object parent, object configContext, System.Xml.XmlNode section)
        {
            Mail mail = new Mail();

            mail.StaffDomain = section.Attributes["staffDomain"] != null ? section.Attributes["staffDomain"].Value : mail.StaffDomain;

            return mail;
        }
开发者ID:mrkurt,项目名称:mubble-old,代码行数:8,代码来源:MailSectionHandler.cs


示例12: Handle

 public async Task Handle(SendMail command, IAggregateRepository repository)
 {
     var mail = new Mail();
     mail.RequestMail(command);
     await repository.Create(mail.RaiseNewEvents());
     await mail.SendMail(this.mailService);
     await repository.Update(mail.RaiseNewEvents());
 }
开发者ID:juicelink,项目名称:EventSourcedMailServer,代码行数:8,代码来源:Handlers.cs


示例13: SendEmail

 public static async Task SendEmail(string email, string subject, string content, EmailConfig config)
 {
     dynamic sg = new SendGridAPIClient(config.SendGridApiKey);
     Email from = new Email(config.EmailFrom);
     Email to = new Email(email);
     Mail mail = new Mail(from, subject, to, new Content("text/html", content));
     dynamic response = await sg.client.mail.send.post(requestBody: mail.Get());
 }
开发者ID:TTCErembodegem,项目名称:TTC-React-Back,代码行数:8,代码来源:EmailService.cs


示例14: GlimpseMail

 public GlimpseMail(Mail Mail)
 {
     if (Mail != null) {
         this.ToEmail = Mail.ToEmail;
         this.ToName = Mail.ToName;
         this.Subject = Mail.Subject;
         this.Body = Mail.Body;
     }
 }
开发者ID:robrich,项目名称:GlimpseMailTab,代码行数:9,代码来源:GlimpseMail.cs


示例15: Test_New

        public void Test_New()
        {
            var from = new Node ("Node1");
            var mail = new Mail (from, "Node2", "Hello World");

            Assert.AreEqual (from, mail.From);
            Assert.AreEqual ("Node2", mail.Address);
            Assert.AreEqual ("Hello World", mail.Letter);
        }
开发者ID:weimingtom,项目名称:erica,代码行数:9,代码来源:TestMail.cs


示例16: DisableClickTracking

        public void DisableClickTracking()
        {
            var header = new Header();
            var sendgrid = new Mail(header);

            sendgrid.DisableClickTracking();

            String json = header.JsonString();
            Assert.AreEqual("{\"filters\" : {\"clicktrack\" : {\"settings\" : {\"enable\" : \"0\"}}}}", json);
        }
开发者ID:advancedrei,项目名称:sendgridplus-csharp,代码行数:10,代码来源:MailTest.cs


示例17: AddHeader

        protected override void AddHeader(MailMessage message, Mail mail)
        {
            SendGridOptions options = _options(mail);

            options.Headers.ToList().ForEach(kvp => message.Headers.Add(kvp.Key, kvp.Value));

            string smtpapi = options.Header.AsJson();
            if (!string.IsNullOrEmpty(smtpapi))
                message.Headers.Add("X-Smtpapi", smtpapi);
        }        
开发者ID:Hylaean,项目名称:Hylaean.Mail,代码行数:10,代码来源:SmtpApiSender.cs


示例18: DisableBypassListManagement

        public void DisableBypassListManagement()
        {
            var header = new Header();
            var sendgrid = new Mail(header);

            sendgrid.DisableBypassListManagement();

            String json = header.JsonString();
            Assert.AreEqual("{\"filters\" : {\"bypass_list_management\" : {\"settings\" : {\"enable\" : \"0\"}}}}", json);
        }
开发者ID:advancedrei,项目名称:sendgridplus-csharp,代码行数:10,代码来源:MailTest.cs


示例19: buttonSend_Click

 protected void buttonSend_Click(object sender, EventArgs e)
 {
     try
     {
         this.sendMail = new Mail(HttpUtility.HtmlEncode(this.txtBoxMail.Text));
         this.sendMail.SendEmailWithNewPassword();
         this.txtBoxMail.Text = "";
     }
     catch { }
 }
开发者ID:jimowns,项目名称:JimsProjectTestingTools,代码行数:10,代码来源:LoginView.aspx.cs


示例20: DisableBcc

        public void DisableBcc()
        {
            var header = new Header();
            var sendgrid = new Mail(header);

            sendgrid.DisableBcc();

            String json = header.AsJson();
            Assert.AreEqual("{\"filters\" : {\"bcc\" : {\"settings\" : {\"enable\" : \"0\"}}}}", json);
        }
开发者ID:rstepehenson,项目名称:sendgridplus-csharp,代码行数:10,代码来源:MailTest.cs



注:本文中的Mail类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# MailAddress类代码示例发布时间:2022-05-24
下一篇:
C# Maid类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap