Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

WoodsPhreaker

[Resolvido] Script completo para envio de mesagens de Feliz Anive

Recommended Posts

Bom pessoal, depois de muito penar aqui, recebi a ajuda do nosso amigo Ted k, consegui terminar o script para envio de mensagens automáticas de Feliz Aniversário, baseadas em datas de nascimento cadastradas previamente pelos clientes.

 

Pode ser colocado em qualquer parte do seu site, pois ele verifica se a mensagem já foi enviada, caso positivo ele aborta a função, caso negativo, completa o loop e envia uma mensagem padrão para todos os clientes com a data igual a atual. Completanto, a data foi tratada somente por DD/MM então o ano é ignorado, deixando assim mais eficaz.

 

Se alguém quiser aperfeiçoa-lo, fiquem a vontade.

 

<% 
'Verifica se o email já foi enviado
Set DB = Server.CreateObject("ADODB.Connection")
Caminho="C:\Inetpub\wwwroot\Site\Database\BD.mdb"
ConexaoBD = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Caminho&";"
DB.Open (ConexaoBD)
Set rs = Server.CreateObject("ADODB.Recordset")
sql=  "SELECT verificadata FROM verificadata"
rs.Open sql, DB, 3, 3
if LEFT(Now(),5) = rs("verificadata") then 
rs.Close
Set DB = nothing
Set rs = Nothing 
else
rs.Close
Set DB = nothing
Set rs = Nothing 
' rotina 1 terminada 
'############################################################################
##################################################	
'Rotina 2 iniciada ( conexão com BD )
session.lcid=1046  
Set DB = Server.CreateObject("ADODB.Connection")
Caminho="C:\Inetpub\wwwroot\Site\Database\BD.mdb"
ConexaoBD = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Caminho&";"
DB.Open (ConexaoBD)
Set rs = Server.CreateObject("ADODB.Recordset")
sql=  "SELECT * FROM clientes where LEFT(nascimento,5) = LEFT(Now(),5) ORDER by clienteid asc"
rs.Open sql, DB, 3, 3 
if rs.EOF or BOF then 
'caso nenhum registro seja encontrado, termina a rotina
response.end
else 
' achando registros, a função continua
While Not rs.EOF
nome = rs("nome") 
data = rs("nascimento")
email = rs("email")
'############################################################################
##################################################	
'inicio do corpo da mensagem que será enviada por e-mail  - personalize como quiser
strTextoHtml = strTextoHtml & "<table width=100% border=1 align=center cellpadding=0 cellspacing=5 summary=>" &vbnewline
strTextoHtml = strTextoHtml & "<tr>" &vbnewline
strTextoHtml = strTextoHtml & "<td width=20% align=right valign=middle>Nome:</td>" &vbnewline
strTextoHtml = strTextoHtml & "<td width=80% align=left valign=middle>" &UCASE(nome)&" </td>" &vbnewline
strTextoHtml = strTextoHtml & "</tr>" &vbnewline
strTextoHtml = strTextoHtml & "<tr>" &vbnewline
strTextoHtml = strTextoHtml & "<td width=20% align=right valign=middle>Data Niver:</td>" &vbnewline
strTextoHtml = strTextoHtml & "<td width=80% align=left valign=middle>" &UCASE(data)& "</td>" &vbnewline
strTextoHtml = strTextoHtml & "</tr>" &vbnewline
strTextoHtml = strTextoHtml & "<tr>" &vbnewline
strTextoHtml = strTextoHtml & "<td width=20% align=right valign=middle>Email:</td>" &vbnewline
strTextoHtml = strTextoHtml & "<td width=80% align=left valign=middle>" &UCASE(email)& "</td>" &vbnewline
strTextoHtml = strTextoHtml & "</tr>" &vbnewline
strTextoHtml = strTextoHtml & "</table>" &vbnewline
'fim do corpo da mensagem que será enviada por e-mail 
'############################################################################
##################################################	

'############################################################################
##################################################	
' inicio da rotina e-mail
'Set Mail = Server.CreateObject("Persits.MailSender")
'Mail.Host = "localhost"
'Mail.From = "seuemail@provedor.com.br"
'Mail.FromName = "Feliz Aniversário "&nome&""
'Mail.AddReplyTo "seuemail@provedor.com.br"
'Mail.AddAddress email
'Mail.Subject = "Parabéns pelo seu dia"
'Mail.isHTML = true
'Mail.Body = strTextoHtml	 	
'Mail.Send
'Set Mail = nothing	
'############################################################################
##################################################	
rs.movenext
Wend
end if
rs.Close
Set rs = Nothing 
'############################################################################
##################################################	
'grava a data atual para verificação posterior 
Set rs = Server.CreateObject("ADODB.Recordset")
sql=  "SELECT verificadata FROM verificadata"
rs.Open sql, DB, 3, 3
rs("verificadata") = LEFT(Now(),5)
rs.update
rs.Close
Set rs = Nothing 
end if
'############################################################################
##################################################	
%>
<%
' retire essa parte, só coloquei para testar o retorno da variável
response.write strTextoHtml	
%>

É isso aí ... http://forum.imasters.com.br/public/style_emoticons/default/natal_smile.gif

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.