Results 1 to 3 of 3

Thread: Why page not launching

  1. #1
    .NET Framework
    .NET 4.5
    Join Date
    Aug 2014

    Why page not launching


    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:

    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:


    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.

    Last edited by keymaker; 04-06-2018 at 5:56 AM.

  2. #2
    .NET Framework
    .NET 4.0
    Join Date
    Aug 2004
    Sydney, Australia
    You need to call Send on your SmtpClient in order to send an email via the specified server.

  3. #3
    .NET Framework
    .NET 4.5
    Join Date
    Aug 2014
    Sorry for not posting the rest of the 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("") '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='" & uniqueCode & "' style='color: #0000FF; text-decoration: none;'>link</a><br /><br />Thank you<br /><br />Regards<br /></br />Dima<br /><br ><a href='' target='_blank' style='color: #0000FF; text-decoration: none;'></a></body>", Nothing, "text/html")
                Dim Logo As New LinkedResource(Server.MapPath("~/Images/dimaHeader.jpg"), "image/jpeg") 'embedded image
                Logo.ContentId = "dimaHeader"
                Smtpserver.DeliveryMethod = SmtpDeliveryMethod.Network
                Smtpserver.Host = ("mail.server")
                Smtpserver.Port = 25
                Smtpserver.EnableSsl = False
                Dim basicAuthenticationInfo As New System.Net.NetworkCredential("", "pwd")
                Smtpserver.Credentials = basicAuthenticationInfo
                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:

    <a href='" & 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.

Similar Threads

  1. Question Launching application as opensource
    By wasimking in forum Deployment
    Replies: 0
    Last Post: 05-23-2012, 6:22 AM
  2. Launching Applications using WMI
    By DanielBlackmore in forum VB.NET General Discussion
    Replies: 2
    Last Post: 03-12-2010, 2:14 PM
  3. Question Differences in launching new threads
    By sebadinoist in forum Windows Services
    Replies: 3
    Last Post: 01-07-2009, 1:19 PM
  4. switchboard for launching AutoCAD?
    By zendog1960 in forum Console Application
    Replies: 4
    Last Post: 01-25-2008, 1:09 PM
  5. Launching PDF without saving it first
    By ninel in forum Reporting / Printing
    Replies: 0
    Last Post: 04-11-2006, 12:45 PM


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts