Pagina 1 di 3 1 2 3 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 22
  1. #1
    Utente di HTML.it
    Registrato dal
    May 2001
    Messaggi
    387

    Non riesco a inviare e-mail

    Ciao,
    sono un novizio in ambito asp.net,
    mi serve realizzare un modulo per l'invio di e-mail,
    nella rete ho trovato questo codice:

    codice:
    <script language="vb" runat="server">
    
    Sub btnSendFeedback_Click(sender as Object, e as EventArgs)
    
      'Create an instance of the MailMessage class
      Dim objMM as New MailMessage()
    
      'Set the properties - send the email to the person who filled out the
      'feedback form.
      objMM.To = "info@miosito.it"
      objMM.From = txtEmail.Text
    
      
    
      'Send the email in text format
      objMM.BodyFormat = MailFormat.Text
      '(to send HTML format, change MailFormat.Text to MailFormat.Html)
    
      'Set the priority - options are High, Low, and Normal
      objMM.Priority = MailPriority.Normal
    
      'Set the subject
      objMM.Subject = "4GuysFromRolla.com - Feedback"
    
      'Set the body
      objMM.Body = "At " + DateTime.Now + " feedback was sent from an ASP.NET " & _
                   "Web page.  Below you will find the feedback message " & _
                   "send by " & txtName.Text & "." & vbCrLf & vbCrLf & _
                   "---------------------------------------" & vbCrLf & vbCrLf & _
                   txtMessage.Text & vbCrLf
    
      
      'Specify to use the default Smtp Server
      SmtpMail.SmtpServer = ""
      
      'Now, to send the message, use the Send method of the SmtpMail class
      SmtpMail.Send(objMM)
    
    
      panelSendEmail.Visible = false
      panelMailSent.Visible = true
    End Sub
    
    </script>
    
    <html>
    <body>
      <asp:panel id="panelSendEmail" runat="server">
        <form id="Form1" runat="server">
          <h2>Contatti</h2>
    
          Nome:
          <asp:textbox id="txtName" runat="server" />
          
    
    
          Indirizzo Email:
          <asp:textbox id="txtEmail" runat="server" />
          
    
    
    
          Messaggio:
    
          <asp:textbox id="txtMessage" TextMode="MultiLine"
                          Columns="40" Rows="10" runat="server" />
          
    
    
    
          <asp:button runat="server" id="btnSendFeedback" Text="Send Feedback!"
                      OnClick="btnSendFeedback_Click" />
        </form>
      </asp:panel>
    
    
      <asp:panel id="panelMailSent" runat="server" Visible="False">
        
      </asp:panel>
    </body>
    </html>
    ma quando uplodo la pagina, il modulo contatti non appare proprio!
    come posso fare??
    a presto

  2. #2
    Moderatore di ASP.net L'avatar di djciko
    Registrato dal
    Nov 2002
    Messaggi
    6,887
    codice:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Pagina senza titolo</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
                <asp:panel id="panelSendEmail" runat="server">
                <h2>Contatti</h2>
                Nome:
                <asp:textbox id="txtName" runat="server" />
                
    
                Indirizzo Email:
                <asp:textbox id="txtEmail" runat="server" />
                
    
    
                Messaggio:
    
                <asp:textbox id="txtMessage" TextMode="MultiLine" Columns="40" Rows="10" runat="server" />
               
    
    
               <asp:button runat="server" id="btnSendFeedback" Text="Send Feedback!"
                      onClick="btnSendFeedback_Click" />
               </form>
               </asp:panel>
              <asp:panel id="panelMailSent" runat="server" Visible="False"></asp:panel>
        </div>
        </form>
    </body>
    </html>

  3. #3
    <aspanel id="panelSendEmail" runat="server">
    <form id="Form1" runat="server">
    questo mi sembra un errore: il panel deve stare dentro il form

  4. #4
    Utente di HTML.it
    Registrato dal
    May 2001
    Messaggi
    387
    ho cambiato il codice in questo modo ma il risultato non cambia

    codice:
       <form id="Form1" runat="server">
        <asp:panel id="panelSendEmail" runat="server">
          <h2>Contatti</h2>
    
          Nome:
          <asp:textbox id="txtName" runat="server" />
          
    
    
          Indirizzo Email:
          <asp:textbox id="txtEmail" runat="server" />
          
    
    
    
          Messaggio:
    
          <asp:textbox id="txtMessage" TextMode="MultiLine"
                          Columns="40" Rows="10" runat="server" />
          
    
    
    
          <asp:button runat="server" id="btnSendFeedback" Text="Send Feedback!"
                      OnClick="btnSendFeedback_Click" />
         </asp:panel>              
        </form>

  5. #5
    Moderatore di ASP.net L'avatar di djciko
    Registrato dal
    Nov 2002
    Messaggi
    6,887
    prova a copiare il codice che ti ho scritto.. forse e' un problema di doctype o altro, anche se non ho capito l'utilità del secondo pannello, panelMailSent, che e' vuoto...

  6. #6
    Utente di HTML.it L'avatar di pietro09
    Registrato dal
    Jan 2002
    Messaggi
    10,116
    Questo va

    codice:
    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="a.aspx.vb" Inherits="prove_a" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <asp:Panel ID="panelSendEmail" runat="server">
            <form id="Form1" runat="server">
            <h2>
                Contatti</h2>
            Nome:
            <asp:TextBox ID="txtName" runat="server" />
            
    
            Indirizzo Email:
            <asp:TextBox ID="txtEmail" runat="server" />
            
    
    
                Messaggio:
    
                <asp:TextBox ID="txtMessage" TextMode="MultiLine" Columns="40" Rows="10" runat="server" />
            
    
    
                <asp:Button runat="server" ID="btnSendFeedback" Text="Send Feedback!" OnClick="btnSendFeedback_Click" />
            </form>
        </asp:Panel>
        <asp:Panel ID="panelMailSent" runat="server" Visible="False">
        </asp:Panel>
    </body>
    </html>
    ====================================================================================================
    Option Strict On
    
    Partial Class prove_a
        Inherits System.Web.UI.Page
    
        Sub btnSendFeedback_Click(ByVal sender As Object, ByVal e As EventArgs)
    
            'Create an instance of the MailMessage class
            Dim objMM As New Web.Mail.MailMessage()
    
            'Set the properties - send the email to the person who filled out the
            'feedback form.
            objMM.To = "xxx@yyy"
            objMM.From = txtEmail.Text
    
    
    
            'Send the email in text format
            objMM.BodyFormat = Web.Mail.MailFormat.Text
            '(to send HTML format, change MailFormat.Text to MailFormat.Html)
    
            'Set the priority - options are High, Low, and Normal
            objMM.Priority = Web.Mail.MailPriority.Normal
    
            'Set the subject
            objMM.Subject = "4GuysFromRolla.com - Feedback"
    
            'Set the body
            objMM.Body = "At " + DateTime.Now.ToShortDateString + " feedback was sent from an ASP.NET " & _
                         "Web page.  Below you will find the feedback message " & _
                         "send by " & txtName.Text & "." & vbCrLf & vbCrLf & _
                         "---------------------------------------" & vbCrLf & vbCrLf & _
                         txtMessage.Text & vbCrLf
    
    
            'Specify to use the default Smtp Server
            Web.Mail.SmtpMail.SmtpServer = ""
    
            'Now, to send the message, use the Send method of the SmtpMail class
            Web.Mail.SmtpMail.Send(objMM)
    
    
            panelSendEmail.Visible = False
            panelMailSent.Visible = True
        End Sub
    
    End Class
    Pietro

  7. #7
    Utente di HTML.it
    Registrato dal
    May 2001
    Messaggi
    387
    non riesco ancora a mandare..
    ho ricopiato il codice nella pagina in cui vi è da inserire il form, mi sono creato una classe e incollato quello che hai scritto ma il visual web developer 2008 mi dice che
    1) bisogna usare net.mail.mailmassage perchè l'altro è obsoleto
    2) non riesce a riconoscere gli elementi che compongono la panel...

  8. #8
    Utente di HTML.it L'avatar di pietro09
    Registrato dal
    Jan 2002
    Messaggi
    10,116
    Originariamente inviato da Colino
    non riesco ancora a mandare..
    ho ricopiato il codice nella pagina in cui vi è da inserire il form, mi sono creato una classe e incollato quello che hai scritto ma il visual web developer 2008 mi dice che
    1) bisogna usare net.mail.mailmassage perchè l'altro è obsoleto
    2) non riesce a riconoscere gli elementi che compongono la panel...
    Il codice che ti ho mandato (che è pressochè uguale al tuo) funziona perfettamente (l'ho provato). Quella classe è obsoleta, ma funziona tuttora.
    Pietro

  9. #9
    Utente di HTML.it L'avatar di pietro09
    Registrato dal
    Jan 2002
    Messaggi
    10,116
    ma hai valorizzato questo?

    objMM.To = "xxx@yyy"


    ripeto che ho riprovato e va (anche se metti (sbagliando) i panel fuori del form)
    Pietro

  10. #10
    Utente di HTML.it L'avatar di pietro09
    Registrato dal
    Jan 2002
    Messaggi
    10,116
    codice:
    <body>
        <form id="Form1" runat="server">
        <asp:Panel ID="panelSendEmail" runat="server">
            <h2>
                Contatti</h2>
            Nome:
            <asp:TextBox ID="txtName" runat="server" />
            
    
            Indirizzo Email:
            <asp:TextBox ID="txtEmail" runat="server" />
            
    
    
                Messaggio:
    
                <asp:TextBox ID="txtMessage" TextMode="MultiLine" Columns="40" Rows="10" runat="server" />
            
    
    
                <asp:Button runat="server" ID="btnSendFeedback" Text="Send Feedback!" OnClick="btnSendFeedback_Click" />
        </asp:Panel>
        <asp:Panel ID="panelMailSent" runat="server" Visible="False">
            Posta inviata
        </asp:Panel>
        </form>
    </body>
    quando spedisci la posta, non compare niente perchè il modulo viene reso invisibile:

    panelSendEmail.Visible = False

    mentre viene reso visibile l'altro
    panelMailSent.Visible = True

    che però è vuoto. Prova a metterci qualcosa dentro e poi fai sapere
    Pietro

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.