Visualizzazione dei risultati da 1 a 4 su 4
  1. #1
    Utente di HTML.it
    Registrato dal
    Jul 2005
    Messaggi
    2,630

    Inviare per mail solo i campi pieni

    Cari amici,
    ho questo script:


    HTML = "<html><head>" &_
    "<HEAD>"&_
    "</HEAD>"&_
    "<BODY bgcolor=""#FFFFFF"" text=""#000080"">"&_
    "<P align=""center"">"&_
    "<Font face=""Tahoma"" size=""6"">"&_
    "REGISTRAZIONE
    "&_
    "<P align=""left"">"&_
    "[b]<font size=""2"">Caro Utente, " & Titolo & " " & Altro titolo & " " & Nome & " " & Cognome & " - N° utente " & idUTENTE & "

    "&_
    "<u>Hai selezionato:</u>

    "&_

    "SPK- REGISTRATION = Euro <font size""1"">"& spk1 & "
    "&_

    "SPK2 - REGISTRATION = Euro <font size""1"">"& spk2 & "
    "&_

    "STUDENTE - REGISTRATION = Euro <font size""1"">" & studente1 & "
    "&_

    "STUDENTE2 - REGISTRATION = Euro <font size""1"">" & studente2 & "
    "&_


    "
    "&_
    "Totale = Euro " & euro & "

    "&_
    "</p></body>" &_
    "</html>"

    Dim objMail, objConfig

    Set objMail = CreateObject("CDO.Message")

    Set objConfig = Server.CreateObject("CDO.Configuration")

    With objConfig

    .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "miosmtp"

    .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

    .Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

    .Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

    .Fields.Update

    End With

    Set objMail.Configuration = objConfig

    objMail.From = "da <da@miodominio.it>"

    objMail.To = Email

    ' Cc e Bcc
    objMail.Cc = "a <acc@miodominio.it>"

    objMail.Subject = "Oggetto"

    objMail.Fields("urn:schemas:httpmail:importance"). Value = 2
    objMail.Fields.Update()

    objMail.HTMLBody = HTML

    objMail.Send()

    Set objMail = Nothing
    I dati necessari li prelevo dal db, m,a considerando che i 4 campi alcuni saranno pieni e altri vuoi vorrei che inviasse la mail indicando solo i campi pieni e non tutti e 4.
    Come posso fare?
    Grazie
    G.

  2. #2
    Con una serie di IF
    codice:
    if len(variabile) > 0 then
    HTML = HTML & "valore=" & variabile & vbCrLf
    end if

  3. #3
    Utente di HTML.it
    Registrato dal
    Jul 2005
    Messaggi
    2,630
    Grazie per la risposta,
    ma come li inserisco nello script?
    Se lo metto dove necessariamente mi serve mi dice errore di compilazione.
    Grazie
    G.

  4. #4
    codice:
    
    if len(spk1) > 0 then
    spk1String = "SPK - REGISTRATION = Euro <font size""1"">"& spk1 & "
    "
    end if
    
    if len(spk2) > 0 then
    spk2String = "SPK2 - REGISTRATION = Euro <font size""1"">"& spk2 & "
    "
    end if
    
    if len(studente1) > 0 then
    studente1String = "STUDENTE - REGISTRATION = Euro <font size""1"">"& studente1 & "
    "
    end if
    
    if len(studente2) > 0 then
    studente2String = "STUDENTE 2 - REGISTRATION = Euro <font size""1"">"& studente2 & "
    "
    end if
    
    HTML = "<html><head>" &_
    "<HEAD>"&_
    "</HEAD>"&_
    "<BODY bgcolor=""#FFFFFF"" text=""#000080"">"&_
    "<P align=""center"">"&_
    "<Font face=""Tahoma"" size=""6"">"&_
    "REGISTRAZIONE
    "&_
    "<P align=""left"">"&_
    "[b]<font size=""2"">Caro Utente, " & Titolo & " " & Altro titolo & " " & Nome & " " & Cognome & " - N° utente " & idUTENTE & "
    
    "&_
    "<u>Hai selezionato:</u>
    
    "&_
    spk1 & spk2 & studente1 & studente2 &_
    "
    "&_
    "Totale = Euro " & euro & "
    
    "&_
    "</p></body>" &_
    "</html>"
    
    Dim objMail, objConfig
    
    Set objMail = CreateObject("CDO.Message")
    
    Set objConfig = Server.CreateObject("CDO.Configuration")
    
    With objConfig
    
    .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "miosmtp"
    
    .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    
    .Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    
    .Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
    
    .Fields.Update
    
    End With
    
    Set objMail.Configuration = objConfig
    
    objMail.From = "da <da@miodominio.it>"
    
    objMail.To = Email
    
    ' Cc e Bcc
    objMail.Cc = "a <acc@miodominio.it>"
    
    objMail.Subject = "Oggetto"
    
    objMail.Fields("urn:schemas:httpmail:importance").Value = 2
    objMail.Fields.Update()
    
    objMail.HTMLBody = HTML
    
    objMail.Send()
    
    Set objMail = Nothing

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.