Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ben Ebeling 1 post 21 karma points
    Dec 05, 2012 @ 20:23
    Ben Ebeling
    0

    System.Net.Mail in Umbraco

    Hi All

    I am relatively new to Umbraco so please excuse me if this is a stupid question. I have developed a site originally in Visual Studio and I am now moving it onto Umbraco. The site contains several online forms that use the System.Net.Mail function to send emails from the from to the client.

    Whilst this works fine in the original development, it doesn't seem to work in Umbraco. How can Umbraco handle the VB Code that goes with it? I currently get an error message (shown below)

     The code in Question is:

    <script runat="server">

        Protected Sub Submit_btn_Click(ByVal sender As Object, ByVal e As System.EventArgs)

            Dim body As String

            body = "Name: " & Name_txt.Text & vbCrLf & vbCrLf & "Email: " & Email_txt.Text & vbCrLf & vbCrLf & "Phone: " & Tel_txt.Text & vbCrLf & vbCrLf & "Details: " & Detail_txt.Text & vbCrLf & vbCrLf & "Prefered Contact Method: " & ContactMethod_Drop.Text & vbCrLf & vbCrLf & "Time: " & Time_txt.Text & vbCrLf & vbCrLf & "Date: " & Date_txt.Text

                  

            SendMail(Email_txt.Text, body)

            Name_txt.Text = ""

            Email_txt.Text = ""

            Tel_txt.Text = ""

            Detail_txt.Text = ""

            ContactMethod_Drop.Text = ""

            Time_txt.Text = ""

            Date_txt.Text = ""

           

        End Sub

        Private Sub SendMail(ByVal from As String, ByVal body As String)

            Dim mailServerName As String = "mail.mailserver.co.uk"

            Dim message As MailMessage = New MailMessage(Email_txt.Text, "[email protected]", "Contact Us Request", body)

           

            Dim mailClient As SmtpClient = New SmtpClient

            mailClient.Host = mailServerName

            mailClient.Send(message)

            message.Dispose()

        End Sub

    </script>

     

  • Petr Snobelt 923 posts 1535 karma points
    Dec 07, 2012 @ 10:58
    Petr Snobelt
    0

    Problem is vb.net. convert your code to c# or try declare language like this:

    <%@ Page Language="VB" %>


Please Sign in or register to post replies

Write your reply to:

Draft