Forums & Blog

A SmarterTools-sponsored community.
Welcome to Forums & Blog Sign in | Join | Help
in Search

Sending email from a web page

Last post 09-24-2008 9:10 AM by gusmarquez. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 09-24-2008 9:00 AM

    Sending email from a web page

    hello there:

     I am trying to send email messages from my web page to my account, as a support form. I mean, users go to my web page and can fill a form and send me a message to my email. For this I use two web pages, the first is a html page ant the second a aspx page, this way:

     First Page contains the form: 

    <form id="form" enctype="multipart/form-data" action="enviar.aspx">
                 <div class="rowi">
                 <input name="txtDe" type="text" class="input" value="Nombre: " />
                 </div>
                 <div class="rowi">
                 <input name="txtEmail" type="text" class="input" value="E-mail:" />
                 </div>
                 <div class="rowt">
                 <textarea name="txtMensaje" cols="1" rows="1">Mensaje:</textarea>
                 <br />
                 <label>
                 <input name="Enviar" type="submit" id="Enviar" value="Enviar" />
                 </label>
                 </div>
    </form>
    <asp:Button ID="cmdEnviar" runat="server" OnClick="cmdEnviar_Click" Text="Enviar" />

     

    Second page, gets the info from the form, creates the net.mail object and sends the email:

    <%@ Page Language ="VB" debug="true" %>
    <%@ Import Namespace="System.Net.Mail"%>
    <%
        On Error Resume Next
        Dim objMail As New System.Net.Mail.MailMessage()
        Dim Direccion As String = Request("txtEmail")
        objMail.From = New MailAddress(Direccion)
        objMail.To.Add("proyectos@ingesoingenieria.com")
        objMail.Subject = "Contacto desde Página Web"
        objMail.Priority = MailPriority.High
        objMail.Body = "" & Request("txtDe") & " escribió: " & vbNewLine & vbNewLine & Request("txtMensaje")
        Dim oclient As SmtpClient = New SmtpClient("mail.ingesoingenieria.com")
        oclient.UseDefaultCredentials = False
        oclient.Credentials = New System.Net.NetworkCredential("gmarquez@ingesoingenieria.com", "xxxxxxxx")
        objMail = Nothing
        oclient = Nothing
    %>

    the problem is that I DON'T GET ANY MESSAGE. Can anyone help me?

  • 09-24-2008 9:10 AM In reply to

    Re: Sending email from a web page

    LOL!

     I hadn't written the final line:

    oclient.Send(objMail.From.ToString, objMail.To.ToString, objMail.Subject, objMail.Body)

    So, the mail message was never sent!

Page 1 of 1 (2 items)