Why page not launching

keymaker

Member
Joined
Aug 13, 2014
Messages
12
Programming Experience
Beginner
Hello

My 'forgotten password' page does not send any email to the user which would otherwise contain a link to reset the password. When the link is clicked, a new page, newPassword.aspx, should be displayed for the user to reset the password.

I am trying to identify why the email is not being sent. In my code, I have this:

Code:
If recordExists Then

            Dim builder As New UriBuilder(Request.Url)
            builder.Path = VirtualPathUtility.ToAbsolute("~/newPassword.aspx")
            builder.Query = "uniqueCode=" & HttpUtility.UrlEncode(uniqueCode)

            Dim link As String = builder.Uri.ToString()
            Dim myMessage As New MailMessage
            Dim Smtpserver As New SmtpClient

The file, newPassword.aspx in this code is taking a tilde, and I wonder if that is correct when both forgot.aspx and newPassword.aspx appear together (not in their own separate folders) in Solution Explorer:

SolutionExplorer.jpg


It may be that I am barking up the wrong tree completely but as I say, I am attempting to identify the source of why the forgot.aspx page is not sending the email or launching newPassword.aspx.

Thanks.
 
Last edited:

keymaker

Member
Joined
Aug 13, 2014
Messages
12
Programming Experience
Beginner
Sorry for not posting the rest of the code:

Code:
Dim link As String = builder.Uri.ToString()            Dim myMessage As New MailMessage
            Dim Smtpserver As New SmtpClient
            Dim strEmailValue As String = Request.Form("strEmailTextBox") 'strEmailValue = user email; strEmailTextBox = ID of email field


            'Create the mail message


            myMessage.From = New MailAddress("info@mysite.net") 'Webmaster's email
            myMessage.To.Add(New MailAddress(strEmailValue)) 'user's email
            myMessage.Subject = ("Password Reset Request")
            'myMessage.Body = "Please click on the following link to reset your password: <br/>Link<br/><br/>Thank you<br/>"


            myMessage.Body = ""
            myMessage.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure
            myMessage.IsBodyHtml = True
            myMessage.Priority = MailPriority.Normal


            Dim PlainMessage As AlternateView = AlternateView.CreateAlternateViewFromString("Hello. To reset your password, please click on this link", Nothing, "text/plain")
            Dim mimeType As ContentType = New ContentType("text/html")
            Dim HtmlMessage As AlternateView = AlternateView.CreateAlternateViewFromString("<img src=cid:dimaHeader><br /><br /><br ><body style='font-family:candara; color:#ffffff; background-color:#858585; margin-left:2em;'>Hello " & strEmailValue & "<br /><br /> To reset your password, please click on this <a href='http://www.dimadayoub.net/newPassword.aspx?token=" & uniqueCode & "' style='color: #0000FF; text-decoration: none;'>link</a><br /><br />Thank you<br /><br />Regards<br /></br />Dima<br /><br ><a href='http://www.dimadayoub.net' target='_blank' style='color: #0000FF; text-decoration: none;'>http://www.dimadayoub.net</a></body>", Nothing, "text/html")


            Dim Logo As New LinkedResource(Server.MapPath("~/Images/dimaHeader.jpg"), "image/jpeg") 'embedded image
            Logo.ContentId = "dimaHeader"
            HtmlMessage.LinkedResources.Add(Logo)


            myMessage.AlternateViews.Add(PlainMessage)
            myMessage.AlternateViews.Add(HtmlMessage)


            Smtpserver.DeliveryMethod = SmtpDeliveryMethod.Network
            Smtpserver.Host = ("mail.server")
            Smtpserver.Port = 25
            Smtpserver.EnableSsl = False
            Dim basicAuthenticationInfo As New System.Net.NetworkCredential("info@mysite.net", "pwd")
            Smtpserver.Credentials = basicAuthenticationInfo
            Smtpserver.Send(myMessage)


            myMessage.Dispose()
            myMessage = Nothing
            Smtpserver = Nothing


            End Sub
After confirming that the user exists in the database, the above should send an HTML-based email to the user that contains this link:

Code:
<a href='http://www.dimadayoub.net/newPassword.aspx?token=" & uniqueCode & "' style='color: #0000FF; text-decoration: none;'>link</a>
On clicking that link, the user should be directed to newPassword.aspx - that's my understanding, anyway.

Thanks again.
 
Top Bottom