Torna al Thread
public partial class UserRegistration : PageBaseClass
{
protected void Page_Init(object sender, EventArgs e)
{
if (Session["registrazione"] == null)
Response.Redirect("~/registra.aspx");
if (!_website.AllowUserSelfRegistration)
Response.Redirect("~/Login.aspx", true);
createUserWizard.CreatedUser += new EventHandler(createUserWizard_CreatedUser);
}
void createUserWizard_CreatedUser(object sender, EventArgs e)
{
string azienda;
string contatto;
string indirizzo;
string cap;
string citta;
string telefono;
//Send email to user for verifying account
MembershipUser user = Membership.GetUser(createUserWizard.UserName);
string url = string.Concat("http://", Request.Url.Authority, Response.ApplyAppPathModifier("~/Login.aspx?activate="));
MailMessage mail = new MailMessage(_website.MailSenderAddress, user.Email);
mail.SubjectEncoding = System.Text.Encoding.UTF8;
mail.Subject = string.Format(Resources.StringsRes.pge_UserRegistration_ActivationEmailSubject, _website.WebSiteTitle);
mail.BodyEncoding = System.Text.Encoding.UTF8;
mail.IsBodyHtml = false;
mail.Body = string.Format(Resources.StringsRes.pge_UserRegistration_ActivationEmailBody, _website.WebSiteTitle, url, user.ProviderUserKey.ToString());
SmtpClient client = new SmtpClient(_website.SmtpServer);
//when Smtp user/password/domain is given, SMTP-Authentication has to be used
if (_website.SmtpUser != "" && _website.SmtpPassword != "" && _website.SmtpDomain != "")
{
client.UseDefaultCredentials = false;
client.Credentials = new NetworkCredential(_website.SmtpUser, _website.SmtpPassword, _website.SmtpDomain);
}
client.Send(mail);
SmtpClient sc = new SmtpClient();
if (Session["azienda"] != null)
{
azienda = Session["azienda"].ToString();
}
else
{
azienda = "";
}
if (Session["contatto"] != null)
{
contatto = Session["contatto"].ToString();
}
else
{
contatto = "";
}
if (Session["indirizzo"] != null)
{
indirizzo = Session["indirizzo"].ToString();
}
else
{
indirizzo = "";
}
if (Session["cap"] != null)
{
cap = Session["cap"].ToString();
}
else
{
cap = "";
}
if (Session["citta"] != null)
{
citta = Session["citta"].ToString();
}
else
{
citta = "";
}
if (Session["telefono"] != null)
{
telefono = Session["telefono"].ToString();
}
else
{
telefono = "";
}
//Send email to user for verifying account
MailMessage messaggio = new MailMessage();
messaggio.From = new MailAddress("webmaster@webmaster.it", "webmaster@webmaster.it");
// messaggio.To.Add(new MailAddress(dr["mailinterne"].ToString()));
messaggio.To.Add(new MailAddress("atopi@tecno-soft.it"));
messaggio.Subject = "NUOVA RICHIESTA DOWNLOAD";
messaggio.SubjectEncoding = System.Text.Encoding.UTF8;
messaggio.Body += "<p>Nome Azienda: " + Server.HtmlEncode(azienda);
messaggio.Body += "<br>Persona da contattare: " + Server.HtmlEncode(contatto);
messaggio.Body += "<br>Indirizzo: " + Server.HtmlEncode(indirizzo);
messaggio.Body += "<br>cap: " + Server.HtmlEncode(cap);
messaggio.Body += "<br>città: " + Server.HtmlEncode(citta);
messaggio.Body += "<br>telefono: " + Server.HtmlEncode(telefono);
messaggio.Body += "<br>utente: " + Server.HtmlEncode(createUserWizard.UserName);
messaggio.BodyEncoding = System.Text.Encoding.UTF8;
messaggio.IsBodyHtml = true;
if (_website.SmtpUser != "" && _website.SmtpPassword != "" && _website.SmtpDomain != "")
{
client.UseDefaultCredentials = false;
client.Credentials = new NetworkCredential(_website.SmtpUser, _website.SmtpPassword, _website.SmtpDomain);
}
sc.Send(messaggio);
Session["registrazione"] = null;
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
(createUserStep.ContentTemplateContainer.FindControl("EmailRegexValidator") as RegularExpressionValidator).ValidationExpression = Validation.EmailRegex;
}
}
}