AsyncSendEmail() public static method

Sends an email.
public static AsyncSendEmail ( string recipient, string sender, string subject, string body, bool html ) : void
recipient string The recipient.
sender string The sender.
subject string The subject.
body string The message body.
html bool true if the body is HTML.
return void
Example #1
0
        protected void btnSend_Click(object sender, EventArgs e)
        {
            lblSendResult.Text     = "";
            lblSendResult.CssClass = "";

            Page.Validate();
            if (!Page.IsValid)
            {
                return;
            }

            UserInfo loggedUser = SessionFacade.GetCurrentUser();

            Log.LogEntry("Sending Email to " + currentUser.Username, EntryType.General, loggedUser.Username);
            EmailTools.AsyncSendEmail(currentUser.Email,
                                      "\"" + Users.GetDisplayName(loggedUser) + "\" <" + Settings.SenderEmail + ">",
                                      txtSubject.Text,
                                      Users.GetDisplayName(loggedUser) + " sent you this message from " + Settings.WikiTitle + ". To reply, please go to " + Settings.MainUrl + "User.aspx?Username="******"&Subject=" + Tools.UrlEncode("Re: " + txtSubject.Text) + "\nPlease do not reply to this Email.\n\n------------\n\n" + txtBody.Text,
                                      false);
            lblSendResult.Text     = Properties.Messages.MessageSent;
            lblSendResult.CssClass = "resultok";

            txtSubject.Text = "";
            txtBody.Text    = "";
        }
Example #2
0
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            if (!Settings.UsersCanRegister)
            {
                return;
            }

            lblResult.Text     = "";
            lblResult.CssClass = "";

            Page.Validate();
            if (!Page.IsValid)
            {
                return;
            }

            // Ready to save the user
            Log.LogEntry("Account creation requested for " + txtUsername.Text, EntryType.General, Log.SystemUsername);
            Users.AddUser(txtUsername.Text, txtDisplayName.Text, txtPassword1.Text, txtEmail1.Text,
                          Settings.AccountActivationMode == AccountActivationMode.Auto, null);

            UserInfo newUser = Users.FindUser(txtUsername.Text);

            // Set membership to default Users group
            Users.SetUserMembership(newUser, new string[] { Settings.UsersGroup });

            if (Settings.AccountActivationMode == AccountActivationMode.Email)
            {
                string body = Settings.Provider.GetMetaDataItem(MetaDataItem.AccountActivationMessage, null);
                body = body.Replace("##WIKITITLE##", Settings.WikiTitle).Replace("##USERNAME##", newUser.Username).Replace("##EMAILADDRESS##", Settings.ContactEmail);
                body = body.Replace("##ACTIVATIONLINK##", Settings.MainUrl + "Login.aspx?Activate=" + Tools.ComputeSecurityHash(newUser.Username, newUser.Email, newUser.DateTime) + "&Username="******"Account Activation - " + Settings.WikiTitle, body, false);
            }

            lblResult.CssClass  = "resultok";
            lblResult.Text      = "<br /><br />" + Properties.Messages.AccountCreated;
            btnRegister.Enabled = false;
            pnlRegister.Visible = false;
        }