Results 1 to 11 of 11

Thread: No link showing in email?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2014
    Posts
    469

    No link showing in email?

    Hello

    I am trying to test emails using the local PickupDirectory. The code seems to work only in that an email is send to the local
    directory, but it appears like this: http://www.bayingwolf.com/testEmail.jpg

    Where it says 'Please click....here..', the 'here' should be a link.

    This is the code I have:

    Code:
     Protected Sub SendPost_Click(ByVal sender As Object, e As System.EventArgs) Handles SendPost.Click
    
    
            Dim SMTPMail As New System.Net.Mail.MailMessage()
            Dim sbody As New StringBuilder()
    
            sbody.Append("Please click <a href='http://usingasp.net/reset_pwd.aspx'>here</a> to reset your password")
    
                If True Then
    
                SMTPMail.From = New MailAddress("me@mycompany.com")
    
                SMTPMail.[To].Add("you@yourcompany.com")
    
                SMTPMail.Subject = "Test Email Using PickupDirectory in Asp.Net"
    
                'SMTPMail.Body = "Test email on local computer"
    
                SMTPMail.Body = sbody.ToString()
    
                'If folder does not exist, create one 
    
                Dim dirInfo As New DirectoryInfo("C:\TestEmails")
    
    
                If Not dirInfo.Exists Then
    
                    'Create new folder 
    
                    Directory.CreateDirectory("C:\TestEmails")
    
                End If
    
                Dim SMTP As New SmtpClient()
    
                SMTP.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory
    
                SMTP.PickupDirectoryLocation = "C:\TestEmails"
    
                SMTP.Send(SMTPMail)
    
            End If
    
        End Sub
    
    End Class
    How can I rectify that, please?

  2. #2
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,398

    Re: No link showing in email?

    If True Then????????? if what true. This also serves n purpose If Not dirInfo.Exists Then, the hTML is plain text. Why should it be magiclly assumed to be html? why do you use stringbuilder for one appending of text?

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2014
    Posts
    469

    Re: No link showing in email?

    The sense would be 'if true show the Email body as HTML'

  4. #4

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2014
    Posts
    469

    Re: No link showing in email?

    This works:

    Code:
    Protected Sub SendPost_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SendPost.Click
    
            Dim SMTPMail As New System.Net.Mail.MailMessage()
    
            Dim sbody As New StringBuilder()
    
            'sbody.Append("Please click <a href='http://usingasp.net/reset_pwd.aspx'>here</a> to reset your password")
    
            'If True Then
    
            SMTPMail.From = New MailAddress("me@mycompany.com") 'This is the Webmaster
            SMTPMail.[To].Add("you@yourcompany.com") 'This is the user
            'SMTPMail.CC.Add("") 'Disallowed: cannot be empty
            SMTPMail.Bcc.Add("Webmaster@mySite.com")
            SMTPMail.From = New MailAddress("info@mySite.net")
            SMTPMail.Subject = "Link to reset your password"
            'SMTPMail.Body = "This contains a link to reset your password"
            SMTPMail.IsBodyHtml = True 'IsBodyHtml is true because HTML tags are included
    
            SMTPMail.Body = "Please click <a href='http://usingasp.net/reset_pwd.aspx'>here</a> to reset your password"
    
            Dim dirInfo As New DirectoryInfo("C:\TestEmails")
    
            If Not dirInfo.Exists Then
    
                Directory.CreateDirectory("C:\TestEmails")
    
            End If
    
            Dim SMTP As New SmtpClient()
    
            SMTP.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory
    
            SMTP.PickupDirectoryLocation = "C:\TestEmails"
    
            Dim mailAuthenticaion As New System.Net.NetworkCredential("info@mySite.com ", "SMTP server password")
    
            Dim SMTPserver As New System.Net.Mail.SmtpClient("smtp.mail.server", 25)
    
            SMTPserver.EnableSsl = True
            SMTPserver.Credentials = mailAuthenticaion
    
            SMTP.Send(SMTPMail)
    
            'End If
    
        End Sub
    but I am sure I have seen it done differently.

    Now I need to show a couple of messages on the screen. In my .aspx file, I have:

    Code:
    <asp:Label ID="Label1" runat="server" Visible="false" Text="Label"></asp:Label>
    Is the following likely to work in my aspx.vb file, please?

    Code:
    Try
        
        Catch ex As Exception
    
        'Display success message
    
        Label1.Text = "A password reset link has been sent to your email address"
    
        Label1.Visible = True
    
    End Try
    
    Else
    
    
        Label1.Text = "Error sending message. Please try again"
    
        Label1.Visible = True
    
    End If
    
    End Try
    Thanks.

  6. #6
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,537

    Re: No link showing in email?

    Wait, so this is all being done from a web page? You're in the wrong spot. I'll ask a mod to move it to the ASP/ASP.NET section where it belongs.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2014
    Posts
    469

    Re: No link showing in email?

    I think I have resolved it now, thanks.

  8. #8
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,902

    Re: No link showing in email?

    Thread moved to ASP forum. Also, if you have resolved your issue please mark the thread as resolved. It helps keep things neat and tidy.

    The sense would be 'if true show the Email body as HTML'
    The thing is that true is always true. So why bother testing for it?
    The best argument against democracy is a five minute conversation with the average voter - Winston Churchill

    Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2014
    Posts
    469

    Re: No link showing in email?

    Thanks, FunkyDexter

    So the logic would be simply 'show the Email body as HTML'.

    Oh, OK you have moved the message. So VB.NET posts go to ASP.NET. I'll try to remember!

    Thanks again.

  10. #10
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,537

    Re: No link showing in email?

    Quote Originally Posted by SteveHi View Post
    Oh, OK you have moved the message. So VB.NET posts go to ASP.NET. I'll try to remember!
    No... only in this case because you're running this code from an ASP.NET webpage... If you were running it from a WinForm application, then the original location would have been correct. ASP.NET has it's own section because there are a few variances in how it operates different from a windows application.

    Quote Originally Posted by SteveHi View Post
    So the logic would be simply 'show the Email body as HTML'.
    The logic needs to be what ever it needs to be. You seem to be always sending the email as HTML ...
    so just do it. There isn't a need for a check.
    It's like saying "If 1=1 then open the door." well 1 will always equal 1... so you always open the door. It's a useless check, just open the door.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2014
    Posts
    469

    Re: No link showing in email?

    Yes, OK thanks!

Posting Permissions

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



Click Here to Expand Forum to Full Width