Visualizzazione dei risultati da 1 a 1 su 1
  1. #1

    Invio news letter con contenuti presi da un database

    Ho fatto molte ricerche ma non ho trovato nessuna soluzione al mio problema.

    Sto realizzando un sito in cui vengo raccolte delle notizie che vengono salavate in una tabella con eventuali documenti allegati.
    Una volta approvatio i vai contenuti devo comporre una news letter con questi contenuti.

    Se carico l'invio di una sola notizia tutto ok ma se le notizie sono 5 non funziona.
    Per chiarezza posto tutto il codice in modo che chi mi aiutasse ha tutto a disposizione.

    codice:
    'Form in cui immetto la data della news letter e il numero della news letter che devo inviare
     <table>
        <tr>
            <td bgcolor="FF8E27"> <span class="titolone">Invio News letter&nbsp;&nbsp;&nbsp;</span></td>
        </tr>
    </table>
    <table bgcolor="#FFFFCC">
    <form action="ConfermaInvioNews.asp" method="post" name="formcheck" id="formcheck" onSubmit="return controllo();">
        <tr>
            <td class="titolo">Data</td>
            <td class="testo"><input name="DataInvio" class="testo" size="10"></td>
        </tr>
        <tr>
            <td class="titolo">Numero News</td>
            <td class="testo"><input name="NumeroNews" class="testo" size="10"></td>
        </tr>
        <tr>
            <td> <input name="InviaModulo" type="submit" id="InviaModulo" value="Invia news letter" class="testo"></td>
        </tr>
    </form>
    </table>

    Ecco il file ConfermaInvioNews.asp in cui faccio partire la mail

    codice:
    <!--#include file="inc/mailobject.asp"-->
    <link rel="stylesheet" href="CSS/Format.css" type="text/css" />
    <%
    Response.Buffer = True
    Dim strPagina, strPagina1
    strpagina1 = Server.Execute("CorpoMail.asp") 'qui metto il contenuto della news letter che pesco dal DB in base alla data e al numero
    strpagina = response.Write(strPagina1)
    
    ConnectDB()
    connectrst()
    
    strSQL = "SELECT * FROM subscriber_list" 'indirizzi mail a cui andrà inviata la mail 
    adoRst.Open strSQL, adoCon, 1, 1
    
    While Not adoRst.EOF
    
    Dim strToEmail, strFromEmail, strSubject, strFormat, strMessage, MailBody
    
    strFormato = "HTML"
    strAdminEmail_ID = "admin@xxxx.it"
    strSoggetto = "Newsletter - Progetto vxyz"
    
    
    strToEmail = adoRst("Email")
    strFromEmail = strAdminEmail_ID
    strSubject = strSoggetto
    strFormat = strFormato
    MailBody = (strpagina)
    
    Call SendMail(strToEmail, strFromEmail, strSubject, strFormat, MailBody)
    
    adoRst.MoveNext
    Wend
    adoRst.Close
    Set adoRst = Nothing
    
    response.redirect("ConfermaRegistrazioneMini.asp")
    %>

    Ecco il file CorpoMail.asp che viene eseguito dalla pagina precedente


    codice:
    <%
    Dim strDataInvio, strNumeroNews, MailBody, CorpoMail, NotizieInterne, strContaAllegati, strTitolo, strStrillo, strLink, strDataNews, strCategoriaNotizia
    strDataInvio = request.form("DataInvio")
    strNumeroNews = request.form("NumeroNews")
    
    ConnectDB()
    connectRS()
    strSQL = "SELECT t_News.IdNews, t_News.Evidenza, t_News.Straordinaria, t_News.Pertinente, t_News.Titolo, t_News.Strillo, t_News.Titolarita, t_News.RealtaCoinvolte, t_News.Luogo, t_News.DoveRivolgersi, t_News.Referente, t_News.Link, t_News.DataNews, t_News.CategoriaNotizia, t_News.Pubblicazione, t_News.DataPubblicazione, t_News.Comuni, t_News.Enti, t_News.Invio, t_News.DataInvio, t_News.utenteinserimento, t_News.DataSalvataggio, t_News.utentemodifica, t_News.DataModifica, t_News.DataServer, t_News.NumeroNews, t_News.NumeroNews, t_News.DataInvio, Count(Allegati.Id) AS ConteggioDiId FROM t_News LEFT JOIN Allegati ON t_News.IdNews = Allegati.IdNews GROUP BY t_News.IdNews, t_News.Evidenza, t_News.Straordinaria, t_News.Pertinente, t_News.Titolo, t_News.Strillo, t_News.Titolarita, t_News.RealtaCoinvolte, t_News.Luogo, t_News.DoveRivolgersi, t_News.Referente, t_News.Link, t_News.DataNews, t_News.CategoriaNotizia, t_News.Pubblicazione, t_News.DataPubblicazione, t_News.Comuni, t_News.Enti, t_News.Invio, t_News.DataInvio, t_News.utenteinserimento, t_News.DataSalvataggio, t_News.utentemodifica, t_News.DataModifica, t_News.DataServer, t_News.NumeroNews, t_News.NumeroNews, t_News.DataInvio HAVING (((t_News.DataInvio)=#"&strDataInvio&"#) AND ((t_News.NumeroNews)="&strNumeroNews&"))"
    
    rs.Open strSQL, adocon, 3, 3
    
    Intestazione = ("<font face=""Verdana, Arial, Helvetica, sans-serif"" color=""#000000"" size=""2""><fieldset style=""border-color:#0000FF"" ><legend>&nbsp;&nbsp;<img src=""http://www.xxxxxx.it/Images/LogoPartecipazione.jpg"" width=""150"" />&nbsp;&nbsp;</legend><br /><br /><br />")
    response.Write(Intestazione)
    i=1 
    do until (rs.eof)
    
    strContaAllegati = rs("ConteggioDiId")
    strTitolo= rs("Titolo")
    strStrillo= rs("Strillo")
    strLink= rs("Link")
    strDataNews= rs("DataNews")
    strCategoriaNotizia= rs("CategoriaNotizia")
    
    If strCategoriaNotizia = 1 Then
        strCategoriaNotizia = "<img src=""http://www.xxxxxx.it/images/Mani_cuore.png"" border=""0""  width=""160"" height=""116"">"
    elseif strCategoriaNotizia = 2 Then
        strCategoriaNotizia = "<img src=""http://www.xxxxxx.it/images/Seminari.png"" border=""0""  width=""160"" height=""116"">"
    elseif strCategoriaNotizia = 3 Then
        strCategoriaNotizia = "<img src=""http://www.xxxxxx.it/images/Registri_Libri.png"" border=""0""  width=""160"" height=""116"">"
    elseif strCategoriaNotizia = 4 Then
        strCategoriaNotizia = "<img src=""http://www.xxxxxx.it/images/Bandi_Finanziamenti.png"" border=""0"" width=""160"" height=""116"">"
    elseif strCategoriaNotizia = 5 Then
        strCategoriaNotizia = "<img src=""http://www.xxxxxx.it/images/Studi_Ricerche.png"" border=""0"" width=""160"" height=""116"">"
    elseif strCategoriaNotizia = 6 Then
        strCategoriaNotizia = "<img src=""http://www.xxxxxx.it/images/Eventi_Iniziative.png"" border=""0"" width=""160"" height=""116"">"
    elseif strCategoriaNotizia = 7 Then
        strCategoriaNotizia = "<img src=""http://www.xxxxxx.it/images/ComunicazioniOrganizzative.png"" border=""0""  width=""160"" height=""116"">"
    elseif strCategoriaNotizia = 8 Then
        strCategoriaNotizia = "<img src=""http://www.xxxxxx.it/images/Altre_Categorie.png"" border=""0"" width=""160"" height=""116"">"
    end if
    
    NotizieInterne = ("<table><tr><td rowspan=""6"" valign=""top""><p>"&strCategoriaNotizia&"</p></td><td class=""testoMaiuscolo""> <br />"&strTitolo&" </td></tr> <tr> <td class=""testo"">"&strStrillo&" </td> </tr><tr><td class=""testo"">Per questa notizia sono presenti: "&strContaAllegati&" allegati</td> </tr> <tr> <td width=""650""> <div align=""right""><a href=http://"&strLink&"><img src=""http://www.xxxxxx.it/Images/bottone_approfindisci.png"" width=""40"" border = ""0"" /></a>&nbsp; APPROFONDISCI</div> </td> </tr><tr><td colspan=""2""><hr width=""100%"" color=""#FFCC00""/></td></tr> </table>")
    response.Write(NotizieInterne)
    i=i+1
    rs.movenext
    loop
    Dim Chiusura
    Chiusura = ("</fieldset>")
    response.Write(Chiusura)
    rs.close
    set rs=nothing
    adocon.close
    set adocon=nothing
    %>

    Se eseguo la pagina CorpoMail.asp senza invio mi appare tutto perfetto ma se viene incluso nel corpo della mail la mail che ricevo è completamente vuota.
    Come posso fare? Avete consigli da darmi?
    Grazie e buon lavoro a tutti!!
    Damiano
    Ultima modifica di j.hornung; 12-01-2015 a 10:26
    :bhò

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.