当前位置: 首页>>代码示例>>C#>>正文


C# Mail.SendMail方法代码示例

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


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

示例1: 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

示例2: Contact

        public ActionResult Contact(string txtEMail, string txtSuggestion)
        {
            if (!string.IsNullOrEmpty(txtSuggestion))
            {
                if (string.IsNullOrEmpty(txtEMail))
                {
                    if (Session["User"] != null)
                    {
                        user = (Users)Session["User"];
                        txtEMail = user.Email;
                    }
                }
                //else
                //{
                //    return View();
                //}
                Mail mail = new Mail();
                mail.Body = txtSuggestion + " from " + txtEMail;
                //if (Session["User"] != null)
                mail.FromAdd = "[email protected]";
                // else
                   // mail.FromAdd = txtEMail;
                mail.Subject = "Suggestion";
                mail.ToAdd = "[email protected]";

                mail.SendMail();
                ViewBag.Ack = "Thank you!! We appreciate your patience and your time in reaching out to us, we will get back to you soon if needed.";

                return View();
            }

            if (Session["User"] != null)
            {
                user = (Users)Session["User"];
                ViewBag.UserEMail = user.Email;
            }

            return View();
        }
开发者ID:joinpramod,项目名称:MyBlogWebsiteMVC2015,代码行数:39,代码来源:HomeController.cs

示例3: Post

        public ActionResult Post(string txtYouTubeLink, HttpPostedFileBase fileArticleWordFile, HttpPostedFileBase fileArticleSourceCode)
        {
            if (Session["User"] != null && fileArticleWordFile != null)
            {
                Mail mail = new Mail();
                mail.Body = "<a>New article from " + user.Email + ", file name is " + fileArticleWordFile.FileName + " Youtube URL - " + txtYouTubeLink + " </a>";
                mail.FromAdd = "[email protected]";
                mail.Subject = "New Article from " + user.Email;
                mail.ToAdd = "[email protected]";

                string strFileName = System.IO.Path.GetFileName(fileArticleWordFile.FileName);
                Attachment attachFile = new Attachment(fileArticleWordFile.InputStream, strFileName);
                mail.FileAttachment = attachFile;

                if (fileArticleSourceCode != null)
                {
                    strFileName = System.IO.Path.GetFileName(fileArticleSourceCode.FileName);
                    attachFile = new Attachment(fileArticleSourceCode.InputStream, strFileName);
                    mail.SourceFileAttachment = attachFile;
                }

                mail.IsBodyHtml = true;

                if (user.Email != "[email protected]")
                {
                    mail.SendMail();
                }

                ViewBag.Acknowledgement = "Article emailed successfully. We will get back to you if needed. Thanks much for your post. Appreciate it. ";
            }

            return View();
        }
开发者ID:joinpramod,项目名称:MyBlogWebsiteMVC2015,代码行数:33,代码来源:ArticlesController.cs

示例4: InsertComment

        public ActionResult InsertComment(string Comment)
        {
            VwArticlesModel model = new VwArticlesModel();
            if (Session["User"] != null)
            {
                if (!string.IsNullOrEmpty(Comment))
                {
                    user = (Users)Session["User"];
                    string articleID = RouteData.Values["Id"].ToString();

                    double dblReplyID = 0;
                    ArticleComments articleComments = new ArticleComments();
                    SqlConnection LclConn = new SqlConnection();
                    SqlTransaction SetTransaction = null;
                    bool IsinTransaction = false;
                    if (LclConn.State != ConnectionState.Open)
                    {
                        articleComments.SetConnection = articleComments.OpenConnection(LclConn);
                        SetTransaction = LclConn.BeginTransaction(IsolationLevel.ReadCommitted);
                        IsinTransaction = true;
                    }
                    else
                    {
                        articleComments.SetConnection = LclConn;
                    }

                    articleComments.OptionID = 1;
                    articleComments.ReplyUserId = user.UserId;
                    articleComments.ArticleId = double.Parse(articleID.ToString());
                    articleComments.ReplyText = Comment;

                    articleComments.InsertedDate = DateTime.Now;

                    bool result = articleComments.CreateArticleComments(ref dblReplyID, SetTransaction);

                    if (IsinTransaction && result)
                    {
                        SetTransaction.Commit();

                        if (!Session["AskedUserEMail"].ToString().Contains("codeanalyze.com"))
                        {
                            Mail mail = new Mail();
                            string strLink = "www.codeanalyze.com/VA.aspx?QId=" + articleID.ToString() + "&QT=" + model.ArticleTitle + "";
                            mail.Body = "<a href=" + strLink + "\\>Click here to view solution to: " + model.ArticleTitle + "</a>";
                            mail.FromAdd = "[email protected]";
                            mail.Subject = "Code Analyze - Received response for " + model.ArticleTitle;
                            mail.ToAdd = Session["AskedUserEMail"].ToString();
                            mail.CCAdds = "[email protected]";
                            mail.IsBodyHtml = true;
                            mail.SendMail();
                        }
                    }
                    else
                    {
                        SetTransaction.Rollback();
                    }
                    articleComments.CloseConnection(LclConn);
                    ViewBag.ReplyId = dblReplyID;
                    model = SetDefaults();
                }
                else
                {
                    ViewBag.lblAck = "Please sign in to post your comment.";
                }

            }
            return View("../Articles/Details", model);
        }
开发者ID:joinpramod,项目名称:MyBlogWebsiteMVC2015,代码行数:68,代码来源:ArticlesController.cs

示例5: ReferFriend

        public ActionResult ReferFriend(string txtReferEMail)
        {
            if (!string.IsNullOrEmpty(txtReferEMail))
            {
                string strFrom = " freinds";
                //if (Session["User"] != null)
                //{
                //user = (Users)Session["User"];
                //if (!string.IsNullOrEmpty(user.FirstName))
                //    strFrom = user.FirstName;
                //else
                //    strFrom = user.Email;
                //}
                Mail mail = new Mail();

                string EMailBody = System.IO.File.ReadAllText(Server.MapPath("../EMailBody.txt"));
                string strCA = "<a id=HyperLink1 style=font-size: medium; font-weight: bold; color:White href=http://codeanalyze.com>CodeAnalyze</a>";
                mail.Body = string.Format(EMailBody, "You have been refered to " + strCA + " by one of your " + strFrom + ". Get Rewards Amazon Gift Cards for code blogging. Do take a look");

                mail.FromAdd = "[email protected]";
                mail.Subject = "Referred to CodeAnalyze";
                mail.ToAdd = txtReferEMail;
                mail.IsBodyHtml = true;
                mail.SendMail();
                txtReferEMail = "Done";
            }
            Response.Redirect("../Articles/Index");
            return null;
            //}
        }
开发者ID:joinpramod,项目名称:MyBlogWebsiteMVC2015,代码行数:30,代码来源:MasterController.cs

示例6: InsertAns


//.........这里部分代码省略.........
                if (LclConn.State != ConnectionState.Open)
                {
                    replies.SetConnection = replies.OpenConnection(LclConn);
                    SetTransaction = LclConn.BeginTransaction(IsolationLevel.ReadCommitted);
                    IsinTransaction = true;
                }
                else
                {
                    replies.SetConnection = LclConn;
                }

                replies.OptionID = 1;
                replies.QuestionId = double.Parse(quesID.ToString());

                //CleanBeforeInsert(ref SolutionEditor, ref strTemp);

                replies.Reply = SolutionEditor;

                replies.RepliedDate = DateTime.Now;

                if (user.UserId == 1)
                {
                    int[] myy = new int[38] { 16, 17, 18, 19, 23, 24, 25, 26, 32, 34, 35, 37, 39, 40, 41, 42, 44, 45, 46, 47, 48, 51, 52, 54, 55, 56, 57, 58, 59, 63, 69, 70, 71, 72, 73, 82, 104, 106 };
                    Random ran = new Random();
                    int mynum = myy[ran.Next(0, myy.Length)];
                    replies.RepliedUser = mynum;

                    int[] myvotes = new int[12] { 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
                    Random ran2 = new Random();
                    int mynum2 = myvotes[ran2.Next(0, myvotes.Length)];
                    replies.UpVotes = mynum2;

                }
                else
                {
                    replies.RepliedUser = user.UserId;
                }

                bool result = replies.CreateReplies(ref dblReplyID, SetTransaction);

                if (IsinTransaction && result)
                {
                    SetTransaction.Commit();
                }
                else
                {
                    SetTransaction.Rollback();
                }

                replies.CloseConnection(LclConn);
                ViewBag.ReplyId = dblReplyID;
                model = SetDefaults();

                try
                {
                    if (!Session["AskedUserEMail"].ToString().Contains("codeanalyze.com"))
                    {
                        Mail mail = new Mail();

                        string EMailBody = System.IO.File.ReadAllText(Server.MapPath("../../../EMailBody.txt"));

                        System.Text.RegularExpressions.Regex rgx = new System.Text.RegularExpressions.Regex("[^a-zA-Z0-9 -]");

                        if (model.QuestionTitle != null)
                        {
                            model.QuestionTitle = rgx.Replace(model.QuestionTitle, "").Replace(" ", "-");
                        }

                        string strLink = "www.codeanalyze.com/Que/Ans/" + quesID.ToString() + "/" + model.QuestionTitle + "";

                        string strBody = "Your question on CodeAnalyse has been answered by one of the users. Check now <a href=" + strLink + "\\>here</a>";

                        mail.Body = string.Format(EMailBody, strBody);

                        mail.FromAdd = "[email protected]";
                        mail.Subject = "Code Analyze - Received response for " + model.QuestionTitle;
                        mail.ToAdd = Session["AskedUserEMail"].ToString();
                        mail.CCAdds = "[email protected]";
                        mail.IsBodyHtml = true;

                        if (!mail.ToAdd.ToString().ToLower().Equals("[email protected]"))
                        {
                            mail.SendMail();
                        }
                    }
                }
                catch(Exception ex)
                {

                }
                //GetQuestionData(quesID.ToString(), ref model);
                //BindSolution("Select * from VwSolutions where QuestionId = " + quesID.ToString(), null);
                //ViewBag.lblAck = string.Empty;
            }
            else
            {
                ViewBag.lblAck = "Please sign in to post your question.";
            }
            return View("../Que/Ans", model);
        }
开发者ID:joinpramod,项目名称:MyBlogWebsiteMVC2015,代码行数:101,代码来源:QueController.cs

示例7: InsertQuestion

        public ActionResult InsertQuestion(string txtTitle, string ddType, string EditorAskQuestion)
        {
            string strTemp = "";
            if (Session["User"] != null)
            {
                txtTitle = txtTitle.Replace("``", "<");
                txtTitle = txtTitle.Replace("~~", "&#");

                user = (Users)Session["User"];
                double dblQuestionID = 0;
                Question question = new Question();
                SqlConnection LclConn = new SqlConnection();
                SqlTransaction SetTransaction = null;
                bool IsinTransaction = false;
                if (LclConn.State != ConnectionState.Open)
                {
                    question.SetConnection = question.OpenConnection(LclConn);
                    SetTransaction = LclConn.BeginTransaction(IsolationLevel.ReadCommitted);
                    IsinTransaction = true;
                }
                else
                {
                    question.SetConnection = LclConn;
                }
                question.QuestionTitle = txtTitle;
                question.QuestionTypeId = int.Parse(ddType);
                question.OptionID = 1;

                //CleanBeforeInsert(ref EditorAskQuestion, ref strTemp);

                question.QuestionDetails = EditorAskQuestion;
                question.AskedDateTime = DateTime.Now;

                if (user.UserId == 1)
                {
                    int[] myy = new int[38] { 16, 17, 18, 19, 23, 24, 25, 26, 32, 34, 35, 37, 39, 40, 41, 42, 44, 45, 46, 47, 48, 51, 52, 54, 55, 56, 57, 58, 59, 63, 69, 70, 71, 72, 73, 82, 104, 106 };
                    Random ran = new Random();
                    int mynum = myy[ran.Next(0, myy.Length)];
                    question.AskedUser = mynum;
                }
                else
                {
                    question.AskedUser = user.UserId;
                }

                bool result = question.CreateQuestion(ref dblQuestionID, SetTransaction);

                if (IsinTransaction && result)
                {
                    SetTransaction.Commit();
                    Mail mail = new Mail();
                    mail.Body = "<a>www.codeanalyze.com/Soln.aspx?QId=" + dblQuestionID.ToString() + "&QT=" + txtTitle + "</a>";
                    mail.FromAdd = "[email protected]";
                    mail.Subject = txtTitle;
                    mail.ToAdd = "[email protected]";
                    mail.IsBodyHtml = true;

                    if (user.Email != "[email protected]")
                    {
                        mail.SendMail();
                    }
                }
                else
                {
                    SetTransaction.Rollback();
                }
                question.CloseConnection(LclConn);

                string title = txtTitle;
                System.Text.RegularExpressions.Regex rgx = new System.Text.RegularExpressions.Regex("[^a-zA-Z0-9 -]");
                txtTitle = rgx.Replace(txtTitle, "");

                string strAck = "Question posted successfully, we will email you when users post answers.<br /> View your posted question ";
                if (Request.Url.ToString().Contains("localhost"))
                    strAck += "<a style=\"color:blue;text-decoration:underline\" href=\"/CodeAnalyzeMVC2015/Que/Ans/" + dblQuestionID.ToString() + "/" + txtTitle.ToString().Replace(" ", "-") + "\">here</a>";
                else
                    strAck += "<a style=\"color:blue;text-decoration:underline\" href=\"http://codeanalyze.com/Que/Ans/" + dblQuestionID.ToString() + "/" + txtTitle.ToString().Replace(" ", "-") + "\">here</a>";
                strAck += "<br />";

                ViewBag.Ack = strAck;
            }

            ConnManager conn = new ConnManager();
            List<QuestionType> items = conn.GetQuestionType();
            QuestionType types = new QuestionType();
            types.Types = items;
            return View("../Que/Post", types);
        }
开发者ID:joinpramod,项目名称:MyBlogWebsiteMVC2015,代码行数:88,代码来源:QueController.cs

示例8: SendNewUserRegEMail

        private void SendNewUserRegEMail(string email)
        {
            try
            {
                Mail mail = new Mail();
                string EMailBody = System.IO.File.ReadAllText(Server.MapPath("../EMailBody.txt"));
                string strCA = "<a id=HyperLink1 style=font-size: medium; font-weight: bold; color:White href=http://codeanalyze.com>CodeAnalyze</a>";
                mail.Body = string.Format(email, "Welcome to " + strCA + ". We appreciate your time for posting code that help many.");
                mail.FromAdd = "[email protected]";
                mail.Subject = "Welcome to CodeAnalyze - Blogger Rewards";
                mail.ToAdd = email;
                mail.IsBodyHtml = true;
                mail.SendMail();
            }
            catch
            {

            }
        }
开发者ID:joinpramod,项目名称:MyBlogWebsiteMVC2015,代码行数:19,代码来源:AccountController.cs

示例9: SendEMail

        private void SendEMail(string Email_address, string firstName, string LastName)
        {
            try
            {
                Mail mail = new Mail();
                mail.Body = "new user email id " + Email_address + " name " + firstName;
                mail.FromAdd = "[email protected]";
                mail.Subject = "New User registered";
                mail.ToAdd = "[email protected]";
                mail.IsBodyHtml = true;
                mail.SendMail();
            }
            catch
            {

            }
        }
开发者ID:joinpramod,项目名称:MyBlogWebsiteMVC2015,代码行数:17,代码来源:AccountController.cs

示例10: ForgotPassword

        //public ActionResult Google()
        //{
        //    return View();
        //}
        public ActionResult ForgotPassword(string txtEMailId)
        {
            if (!string.IsNullOrEmpty(txtEMailId))
            {
                ConnManager con = new ConnManager();
                DataSet dsUser = con.GetData("Select * from Users where Email = '" + txtEMailId + "'");
                con.DisposeConn();
                if (dsUser.Tables[0].Rows.Count <= 0)
                {
                    ViewBag.Ack = "No such EMail Id exists";
                }

                DataTable dtUserActivation = con.GetDataTable("select * from UserActivation where Email = '" + txtEMailId + "'");
                if (dtUserActivation.Rows.Count > 0)
                {
                    ViewBag.Ack = "User activation pending";
                    ViewBag.Activation = "Resend Activation Code?";
                    return View("../Account/Login");
                }

                if (!string.IsNullOrEmpty(dsUser.Tables[0].Rows[0]["Password"].ToString()))
                {
                    Mail mail = new Mail();
                    mail.IsBodyHtml = true;
                    string EMailBody = System.IO.File.ReadAllText(Server.MapPath("EMailBody.txt"));

                    mail.Body = string.Format(EMailBody, "Your CodeAnalyze account password is " + dsUser.Tables[0].Rows[0]["Password"].ToString());

                    mail.FromAdd = "[email protected]";
                    mail.Subject = "Code Analyze account password";
                    mail.ToAdd = dsUser.Tables[0].Rows[0]["EMail"].ToString();
                    mail.SendMail();

                    ViewBag.Ack = "Password has been emailed to you, please check your email.";
                }
                else
                {

                    ViewBag.Ack = "You have created your profile thorugh one of the social sites. Please use the same channel to login. Google Or Facebook";
                }
            }
            return View();
        }
开发者ID:joinpramod,项目名称:MyBlogWebsiteMVC2015,代码行数:47,代码来源:AccountController.cs


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