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


C# Email.Send方法代码示例

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


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

示例1: CreateRestaurant

    public static Restaurant CreateRestaurant(int userId, string name, string food, string restaurantType, int size, string city, string opening, string meals, string drinks)
    {
        Restaurant restaurant = new Restaurant();
        restaurant.UserId = userId;
        restaurant.Name = name;
        restaurant.Food = food;
        restaurant.RestaurantType = restaurantType;
        restaurant.Size = size;
        restaurant.SquareFootage = size * 15;
        restaurant.City = city;
        restaurant.Opening = opening;
        restaurant.Save();

        Answer.CreateAnswersFromTemplate(restaurant, meals, drinks);

        Users user = Users.LoadById(restaurant.UserId);

        if (ConfigurationManager.AppSettings["IsProduction"] == "true")
        {
            string body = string.Format("{0}<br>UserId: {1}<br>Name: {2}<br>Email: {3}", restaurant.Name, user.Id, user.Name, user.Email);
            Email email = new Email("[email protected]", "[email protected]", "New Restaurant", body);
            email.Send();
        }
        HttpContext.Current.Session["CurrentUser"] = user;
        HttpContext.Current.Session["CurrentProspect"] = null;

        return restaurant;
    }
开发者ID:Hookem22,项目名称:BPlan,代码行数:28,代码来源:Default.aspx.cs

示例2: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        if (ConfigurationManager.AppSettings["IsProduction"] != "true")
            return;

        Email email = new Email("[email protected]", "[email protected]", "Visited How it Works Page", "");
        email.Send();
    }
开发者ID:Hookem22,项目名称:BPlan,代码行数:8,代码来源:Default.aspx.cs

示例3: SendEmail

    public static void SendEmail(string subject, string body)
    {
        if (ConfigurationManager.AppSettings["IsProduction"] != "true")
            return;

        body = body.Replace("%20", " ").Replace("%3Cbr%3E", "<br/>").Replace("%3Cbr/%3E", "<br/>");

        Email email = new Email("[email protected]", "[email protected]", subject, body);
        email.Send();
    }
开发者ID:Hookem22,项目名称:BPlan,代码行数:10,代码来源:Default.aspx.cs

示例4: SentResult

        public void SentResult()
        {
            EmailInfo EInfo = InitializeEmailInfo();
            Email senter = new Email();
            string flag="";
            EmailRecordInfo record = new EmailRecordInfo(Listview.CheckedItems[0].SubItems[6].Text, "受听课教师", EInfo.Title, Listview.CheckedItems[0].SubItems[6].Text + DateTime.Now.ToShortTimeString(), "听课反馈结果", flag, FilePath);
            senter.Send(new Email { Type=2,EI=EInfo,ERI=record,id=0,count=0});

            //help.Insert(record,"Logs_Data");
            //MessageBox.Show(flag);
        }
开发者ID:zly071948,项目名称:SAS,代码行数:11,代码来源:EamilResult.cs

示例5: GenerateReport

        public static void GenerateReport(bool debugMode)
        {
            DataSet ds = DB.ExecuteStoredProcedure("sp_Report_CorporateInventory");
            string temporaryDirectory = @"C:\Temp";
            string temporaryFileName = string.Format("TrollbeadsInventory-{0:yyyMMdd}.csv", DateTime.Now);
            string temporaryFilePath = Path.Combine(temporaryDirectory, temporaryFileName);
            FileInfo fi = new FileInfo(temporaryFilePath);

            if (fi.Exists)
                fi.Delete();

            CsvExport myExport = new CsvExport();

            foreach(DataRow dr in ds.Tables[0].Rows)
            {
                myExport.AddRow();
                myExport["ProductNumber"] = dr["ProductNumber"];
                myExport["Description"] = dr["Description"];
                myExport["Category"] = dr["Category"];
                myExport["WholesalePrice"] = dr["WholesalePrice"];
                myExport["RetailPrice"] = dr["RetailPrice"];
                myExport["Quantity"] = dr["Quantity"];
            }

            myExport.ExportToFile(temporaryFilePath);

            if (!debugMode)
            {
                Email email = new Email();

                DataSet recipients = DB.ExecuteStoredProcedure("sp_Report_CorporateInventory_EmailRecipients");
                string to = string.Empty;
                string bcc = string.Empty;
                if (recipients != null && recipients.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow row in recipients.Tables[0].Rows)
                    {
                        string key = string.Format("{0}", row["Key"]);

                        if (key.Equals("reportCorporateInventoryRecipient", StringComparison.InvariantCultureIgnoreCase))
                            to = string.Format("{0}", row["Value"]);

                        if (key.Equals("reportCorporateInventoryRecipientBCC", StringComparison.InvariantCultureIgnoreCase))
                            bcc = string.Format("{0}", row["Value"]);
                    }
                }

                email.Send(to: to, cc: null, bcc: bcc, subject: "Trollbeads Inventory", body: string.Empty, filePathForAttachment: temporaryFilePath);

                fi.Delete();
            }
        }
开发者ID:benharrison,项目名称:tIMS,代码行数:52,代码来源:CorporateInventory.cs

示例6: Execute

 public void Execute(JobExecutionContext context)
 {
     try
     {
         var uri = new Uri(url);
         var request = (HttpWebRequest) WebRequest.Create(uri);
         request.GetResponse();
     }
     catch(Exception ex)
     {
         var email = new Email(ex);
         email.Send();
     }
 }
开发者ID:adzerk,项目名称:DaemonMaster,代码行数:14,代码来源:UrlHitter.cs

示例7: btnSubmit_Click

    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        //Build the body of the Email from the form
        StringBuilder mailBody = new StringBuilder();
        mailBody.Append("Order name is: ");
        mailBody.Append(txtFname.Text);
        mailBody.Append(" ");
        mailBody.Append(txtLname.Text);
        mailBody.Append(System.Environment.NewLine);
        mailBody.Append(" Sex is: ");
        mailBody.Append(rbSex.SelectedValue);
        mailBody.Append(System.Environment.NewLine);
        mailBody.Append(" Credit Card type is: ");
        mailBody.Append(ddCard.SelectedValue);
        mailBody.Append(System.Environment.NewLine);
        mailBody.Append(" Credit Card number is: ");
        mailBody.Append(txtNumber.Text);
        mailBody.Append(System.Environment.NewLine);
        mailBody.Append(" Favorite Student is: ");
        mailBody.Append(ddStudent.SelectedValue);

        Email myEmail = new Email();
        myEmail.Send(mailBody.ToString());
    }
开发者ID:paulortega,项目名称:WEB460_SendEmail,代码行数:24,代码来源:week1.aspx.cs

示例8: Email

        public JsonResult Email(string email, string path)
        {
            string root = ConfigurationManager.AppSettings["FilesRoot"];
            root = root.Trim().EndsWith(@"\") ? root = root.Substring(0, root.Length - 2) : root;

            var fullpath = string.Format(@"{0}{1}", ConfigurationManager.AppSettings["FilesRoot"], path.Replace("/", "\\"));

            var cookie = Request.Cookies["rephidim"];
            if (cookie == null)
            {
                cookie = new HttpCookie("rephidim");
            }
            cookie["email"] = email;
            cookie.Expires = DateTime.Now.AddMonths(12);
            Response.Cookies.Add(cookie);

            dynamic msg = new Email("FileAttach");
            msg.To = email;
            msg.Path = path;
            msg.Attach(new System.Net.Mail.Attachment(fullpath));
            msg.Send();

            return Json(true);
        }
开发者ID:jslaybaugh,项目名称:rephidim-web,代码行数:24,代码来源:FilesController.cs

示例9: buttonX2_Click

        private void buttonX2_Click(object sender, EventArgs e)
        {
            if (listView1.CheckedItems.Count == 1)
            {
                EmailInfo EInfo = InitializeEmailInfo();
                Email senter = new Email();
                string updatecommand = "update Logs_Data set File_State='{flag}'" + "where Time_Now='" + listView1.CheckedItems[0].SubItems[4].Text + "'";
                frmLog log1 = this;
                senter.Send(new Email { Type = 1, EI = EInfo, FL = log1, str = updatecommand });

                if (help.Oledbcommand(updatecommand) > 0)
                {
                    frmLog_Load_1(sender, e);
                }

            }
        }
开发者ID:zly071948,项目名称:SAS,代码行数:17,代码来源:frmLog.cs

示例10: EmailErrorNotification

        /// <summary>
        /// Quietly sends an email error report to [email protected] with additional information
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="info"></param>
        public void EmailErrorNotification(string msg, string info)
        {
            PortalMgr pmgr = PortalMgr.Instance;
            if (pmgr.HttpHost() == "www.amdcc.org")
                return;
            Email email = new Email();

            EmailAddress to = new EmailAddress();
            to.Address = "[email protected]";
            to.DisplayName = "Mike Aufiero";
            EmailAddress from = new EmailAddress();
            from.Address = pmgr.NoReply;
            from.DisplayName = "No Reply";
            email.To.Add(to);
            email.From = from;


            string name = "";
            if (SecurityContext.Current.Member.ID.IsNull)
                name = "**PUBLIC**";
            else
            {
                Member m = SecurityContext.Current.Member;
                name = m.Name;
            }

            email.Subject = "dkCOIN Error Notification";
            email.Body = "The following error message was recently received:\n\n" + msg;
            if (!string.IsNullOrEmpty(info))
                email.Body += "\n\r\rThe following additional information was given:\n\n\r" + info;
            HttpRequest Request = HttpContext.Current.Request;
            if (Request.UserAgent.Contains("Chrome"))
                email.Body += "\n\nBROWSER: " + "Google Chrome" + "\n";
            else email.Body += "\n\nBROWSER: " + Request.Browser.Type + "\n\n";

            email.Body += "HttpHost:\t" + pmgr.HttpHost() + "\r\nName: " + name;
            email.Send();
        }
开发者ID:dkcoin,项目名称:dkCOIN-1.2,代码行数:43,代码来源:DKCoinMgr.cs

示例11: PotentialSummary

    static void PotentialSummary(string body)
    {
        try
        {
            Users user;
            List<Users> users;
            if (body.Contains("Clicked Yes, I do"))
            {
                Random rand = new Random();
                user = new Users() { Id = rand.Next() };
                HttpContext.Current.Session["PotentialUserId"] = user.Id;
                users = HttpContext.Current.Cache.Get("PotentialUsers") as List<Users>;
                if (users == null)
                    users = new List<Users>();

                users.Add(user);
            }
            else
            {
                int userId = (int)HttpContext.Current.Session["PotentialUserId"];
                users = HttpContext.Current.Cache.Get("PotentialUsers") as List<Users>;
                user = users.Find(delegate(Users u)
                {
                    return u.Id == userId;
                });
                if(user == null)
                {
                    user = new Users() { Id = userId };
                }
            }

            user.Name = string.Format("{0}<br/><br/>{1}", user.Name, body);

            HttpContext.Current.Cache.Remove("PotentialUsers");
            HttpContext.Current.Cache.Insert("PotentialUsers", users);

            if (HttpContext.Current.Cache.Get("LastEmailSent") == null)
            {
                HttpContext.Current.Cache.Insert("LastEmailSent", DateTime.Now);
            }
            else
            {
                DateTime lastEmail = (DateTime)HttpContext.Current.Cache.Get("LastEmailSent");
                if (lastEmail.AddMinutes(30) < DateTime.Now)
                {
                    string summary = "All visitors in the last 30 minutes<br/><br/>";
                    foreach (Users u in users)
                    {
                        if(u.Id != user.Id)
                            summary += u.Name + "<br/><br/><br/><br/>";
                    }
                    //summary = summary.Replace("Price $45<br/><br/>", "").Replace("undefined<br/><br/>", "");

                    //Email email1 = new Email("[email protected]", "[email protected]", "Visitor Summary", summary);
                    //email1.Send();
                    Email email2 = new Email("[email protected]", "[email protected]", "Visitor Summary", summary);
                    email2.Send();

                    users = users.FindAll(delegate(Users u)
                    {
                        return u.Id == user.Id;
                    });
                    HttpContext.Current.Cache.Remove("PotentialUsers");
                    HttpContext.Current.Cache.Insert("PotentialUsers", users);

                    HttpContext.Current.Cache.Remove("LastEmailSent");
                    HttpContext.Current.Cache.Insert("LastEmailSent", DateTime.Now);

                }
            }
        }
        catch(Exception ex)
        {
            Email error = new Email("[email protected]", "[email protected]", "Summary error", ex.Message);
            error.Send();

            HttpContext.Current.Cache.Remove("PotentialUsers");
            HttpContext.Current.Cache.Remove("LastEmailSent");

            HttpContext.Current.Cache.Insert("PotentialUsers", new List<Users>());
            HttpContext.Current.Cache.Insert("LastEmailSent", DateTime.Now);
        }
    }
开发者ID:Hookem22,项目名称:BPlan,代码行数:83,代码来源:Default.aspx.cs

示例12: btnPurchase_Click

 protected void btnPurchase_Click(object sender, EventArgs e)
 {
     //create new email object and send a message
     Email email = new Email();
     email.Send(txtFName.Text, txtLName.Text, txtEmail.Text, txtAddr.Text, txtCity.Text, txtState.Text, txtZip.Text, txtCardNum.Text, txtExpDate.Text);
 }
开发者ID:scottbeachy,项目名称:WEB460,代码行数:6,代码来源:Default.aspx.cs

示例13: SendPassword

    public static string SendPassword(string email)
    {
        List<Users> users = Users.LoadByPropName("Email", email);
        if (users.Count == 0 || users[0].Id == 0)
            return "We do not have that email on file.";

        string body = string.Format("Your password for RestaurantBPlan.com is: {0}<br/><br/>Thanks, <br/>Restaurant B Plan Team", users[0].Password);
        Email message = new Email("[email protected]", email, "Restaurant B Plan Password", body);
        message.Send();

        return "";
    }
开发者ID:Hookem22,项目名称:BPlan,代码行数:12,代码来源:Default.aspx.cs

示例14: Subscribe

    public static void Subscribe(Prospect prospect)
    {
        if (ConfigurationManager.AppSettings["IsProduction"] != "true")
            return;

        string name = prospect.Name;
        string restaurantName = prospect.Restaurant;
        string email = prospect.Email;
        if (string.IsNullOrEmpty(name) || name.Contains('@'))
            name = "";
        if (!string.IsNullOrEmpty(name) && name.Contains(' '))
            name = name.Substring(0, name.IndexOf(' '));

        string subject = string.IsNullOrEmpty(name) ? "Let's get started" : name + ", Let's get started";
        if (!string.IsNullOrEmpty(restaurantName))
            subject += " with " + restaurantName;
        name = string.IsNullOrEmpty(name) ? "Hey" : "Hey " + name;
        string body = subscribeEmail.Replace("{Name}", name);

        Email subscribe = new Email("[email protected]", email, subject, body);
        subscribe.Send();
    }
开发者ID:Hookem22,项目名称:BPlan,代码行数:22,代码来源:Default.aspx.cs

示例15: SendNextEmail

    public static void SendNextEmail()
    {
        return;

        if (ConfigurationManager.AppSettings["IsProduction"] != "true")
            return;

        List<Prospect> prospects = Prospect.LoadAll().FindAll(delegate(Prospect p)
        {
            return p.EmailSent >= 1;
        });

        foreach (Prospect prospect in prospects)
        {
            if ((prospect.EmailSent == 1 && prospect.LastEmailSent < DateTime.Now.AddMinutes(-30)) || prospect.LastEmailSent < DateTime.Now.AddHours(-23))
            {
                prospect.EmailSent++;
                prospect.LastEmailSent = DateTime.Now;
                prospect.Save();

                string subject = "";
                string body = "";
                switch(prospect.EmailSent)
                {
                    case 2:
                        {
                            if(!string.IsNullOrEmpty(prospect.Name) && !string.IsNullOrEmpty(prospect.Restaurant))
                            {
                                subject = string.Format("{0}, your business plan for {1}", prospect.Name, prospect.Restaurant);
                                body = sampleEmail.Replace("{Restaurant}", prospect.Restaurant);
                            }
                            else if (!string.IsNullOrEmpty(prospect.Restaurant))
                            {
                                subject = string.Format("Your business plan for {0}", prospect.Restaurant);
                                body = sampleEmail.Replace("{Restaurant}", prospect.Restaurant);
                            }
                            else if (!string.IsNullOrEmpty(prospect.Name))
                            {
                                subject = string.Format("{0}, your business plan from Restaurant BPlan", prospect.Name);
                                body = sampleEmail.Replace("{Restaurant}", "Your Restaurant");
                            }
                            else
                            {
                                subject = "Your business plan from Restaurant BPlan";
                                body = sampleEmail.Replace("{Restaurant}", "Your Restaurant");
                            }
                            break;
                        }
                    case 3:
                        {
                            if(!string.IsNullOrEmpty(prospect.Name))
                            {
                                subject = string.Format("{0}, how much does it cost to open a restaurant?", prospect.Name);
                                body = email3.Replace("{Restaurant}", prospect.Restaurant);
                            }
                            else
                            {
                                subject = "How much does it cost to open a restaurant?";
                                body = email3.Replace("{Restaurant}", "Your Restaurant");
                            }
                            break;
                        }
                    case 4:
                        {
                            if(!string.IsNullOrEmpty(prospect.Name))
                            {
                                subject = string.Format("{0}, don't make these 5 restaurant startup mistakes", prospect.Name);
                                body = email4.Replace("{Restaurant}", prospect.Restaurant);
                            }
                            else
                            {
                                subject = "Don't make these 5 restaurant startup mistakes";
                                body = email4.Replace("{Restaurant}", "Your Restaurant");
                            }
                            break;
                        }
                    case 5:
                        {
                            if (!string.IsNullOrEmpty(prospect.Name))
                            {
                                subject = string.Format("{0}, Get Started on Your Business Plan Today!", prospect.Name);
                                body = email5.Replace("{Restaurant}", prospect.Restaurant).Replace("{Name}", prospect.Name);
                            }
                            else
                            {
                                subject = "Get Started on Your Business Plan Today!";
                                body = email5.Replace("{Restaurant}", "Your Restaurant");
                            }
                            break;
                        }
                    case 6:
                        break;
                }

                if(!string.IsNullOrEmpty(subject))
                {
                    Email email = new Email("[email protected]", prospect.Email, subject, body);
                    email.Send();
                }
            }
//.........这里部分代码省略.........
开发者ID:Hookem22,项目名称:BPlan,代码行数:101,代码来源:Default.aspx.cs


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