Private Sub SendAdminEmail()
Dim config As System.Configuration.Configuration = _
WebConfigurationManager.OpenWebConfiguration( _
HttpContext.Current.Request.ApplicationPath)
Dim settings As System.Net.Configuration.MailSettingsSectionGroup = _
CType(config.GetSectionGroup("system.net/mailSettings"), _
MailSettingsSectionGroup)
'Obtain the Network Credentials from the mailSettings section
Dim credential As New NetworkCredential( _
settings.Smtp.Network.UserName, settings.Smtp.Network.Password)
'Create the SMTP Client
Dim client As New SmtpClient()
client.Host = settings.Smtp.Network.Host
client.Credentials = credential
'Build Email Message
Dim email As New MailMessage
email.From = New MailAddress(ConfigurationManager.AppSettings("FakeEmail"))
For Each address As String In ConfigurationManager.AppSettings("SendToAdmin").Split(New Char() {";"}, StringSplitOptions.RemoveEmptyEntries)
email.To.Add(address)
Next
'email.To.Add(ConfigurationManager.AppSettings("SendToAdmin"))
email.Subject = "New WLR User Account Request"
email.IsBodyHtml = True
email.Body = "<strong>A new user has signed up for access to the WLR</strong>"
email.Body += "<br><br><strong>The following information is viewable once you login.</strong><br><br>"
email.Body += "<br><br><strong>Name:</strong> " + Me.lblVerifyName.Text
email.Body += "<br><strong>Address 1:</strong> " + Me.lblVerifyAdd1.Text
email.Body += "<br><strong>Address 2:</strong> " + Me.lblVerifyAdd2.Text
email.Body += "<br><strong>City:</strong> " + Me.lblVerifyCity.Text
email.Body += "<br><strong>State:</strong> " + Me.lblVerifyState.Text
email.Body += "<br><strong>Zipcode:</strong> " + Me.lblVerifyZip.Text
email.Body += "<br><strong>Phone:</strong> " + Me.lblVerifyPhone.Text
email.Body += "<br><strong>Email:</strong> " + Me.lblVerifyEmail.Text
email.Body += "<br><strong>Company:</strong> " + Me.lblVerifyCompany.Text
'Send Email
client.Send(email)
End Sub
Private Sub CreateRequest()
Dim mr As New WlrHelper.MembershipRequest
mr.Name = txtName.Text.Trim
mr.Address1 = txtAdd1.Text.Trim
mr.Address2 = txtAdd2.Text.Trim
mr.City = txtCity.Text.Trim
mr.State = txtState.Text.Trim
mr.Zip = txtZip1.Text.Trim + IIf(Not String.IsNullOrEmpty(txtZip2.Text.Trim), txtZip2.Text.Trim, "")
mr.Phone = txtPhoneAreaCode.Text.Trim + txtPhonePrefix.Text.Trim + txtPhonePostfix.Text.Trim
mr.Email = txtEmail.Text.Trim
mr.Company = txtCompany.Text.Trim
WlrHelper.Logger.AddMembershipRequest(mr)
End Sub
Protected Sub wizRegister_FinishButtonClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) Handles wizRegister.FinishButtonClick
If Me.CaptchaControl1.UserValidated Then
Try
SendAdminEmail()
CreateRequest()
Me.wizRegister.Visible = False
Me.litFinished.Text = "A request has been submitted for the system administrator(s) to review for account activation! A system administrator my contact you by phone or email with you account information. <br /><br />Upon your first sign in you will be required to change your password." '"An email has been sent to the system administrator requesting account activation. The system administrator my contact you by phone or email with you account information. <br /><br />Upon your first sign in you will be required to change your password."
Me.litFinished.Visible = True
Catch ex As Exception
Me.wizRegister.Visible = False
Me.pnlFinished.Font.Size = FontUnit.Point(10)
Me.pnlFinished.ForeColor = Drawing.Color.Red
Me.litFinished.Text = ex.ToString '"An error occured while trying to create a request for the system administrator(s) to review! Please try again." '"An error occured while trying to send information to the accout administrator! Please try again."
Me.litFinished.Visible = True
End Try
End If
End Sub