/// <summary>
 /// Deprecated Method for adding a new object to the Mail EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToMail(Mail mail)
 {
     base.AddObject("Mail", mail);
 }
 /// <summary>
 /// Create a new Mail object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="fromAddress">Initial value of the FromAddress property.</param>
 /// <param name="toAddress">Initial value of the ToAddress property.</param>
 /// <param name="userName">Initial value of the UserName property.</param>
 /// <param name="passWord">Initial value of the PassWord property.</param>
 /// <param name="serverAddress">Initial value of the ServerAddress property.</param>
 public static Mail CreateMail(global::System.String id, global::System.String fromAddress, global::System.String toAddress, global::System.String userName, global::System.String passWord, global::System.String serverAddress)
 {
     Mail mail = new Mail();
     mail.ID = id;
     mail.FromAddress = fromAddress;
     mail.ToAddress = toAddress;
     mail.UserName = userName;
     mail.PassWord = passWord;
     mail.ServerAddress = serverAddress;
     return mail;
 }
        public ActionResult SendEmail()
        {
            if (Session["NewUser"] != null)
            {
                var User = (DAL.UserInfo)Session["NewUser"];

                DAL.Mail MailMessage = new Mail();
                MailMessage.ID = BLL.BaseUtility.GenerateGUID();
                MailMessage.FromAddress = "*****@*****.**";
                MailMessage.ToAddress = User.Email;
                MailMessage.UserName = "******";
                MailMessage.PassWord = "******";
                MailMessage.ServerAddress = "smtp.task.com";
                MailMessage.Port = 25;
                MailMessage.Subject = Internationalization.Resources.SendEmailSubject;
                MailMessage.Body = Internationalization.Resources.SendEmailBody;

                try
                {
                    DbEntities.Mail.AddObject(MailMessage);
                    DbEntities.SaveChanges();

                    Session["UserLogin"] = Session["NewUser"];
                    Session.Remove("NewUser");
                    ViewData["UserType"] = User.Type;

                    ModelState.AddModelError("", Internationalization.Resources.SendEmailSuccess);
                }
                catch
                {
                    ModelState.AddModelError("", Internationalization.Resources.SendEmailFaield);
                }

                return View();
            }
            else
            {
                return RedirectToAction("LogIn", "Account");
            }
        }