Jump to content
Fórum Script Brasil
  • 0

CDOSYS autenticado


Fabian Kulmann

Question

Pessoal, sou novo em webdesigner, não sei muito sobre programação para não dizer que não sei nada. Tinha um formulário no meu site usando CDONTS, mas mudaram para o CDOSYS autenticado e até hoje não consegui fazer funcionar.

Vou colocar meu script e se alguém puder me dar uma ajuda ficarei muito agradecido. Em vermelho foi o que mudei daquilo que funcionava.

Antecipo meus agradecimentos.

---------------------------------------------------------------------------------------------------------------------------------

<%

'

'Email para onde serão enviados os dados do formulário

email_form = session("emailcontato")

'Título do email

assunto_form = "Contato Site "

'Componente para envio do email: CDOSYS | CDONTS

componente = "CDOSYS"

'senha

senha = "fabian123r"

'Cabeçalho do texto do email recebido

cabecalho_email = "Dados do usuario"

'*******************************************************************

%>

<html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<style>

<!--

.titulo_campos { font-family: Arial; font-size: 10pt; color: #333333 }

input { font-family: Arial; font-size: 10pt; color: #333333 }

textarea { font-family: Arial; font-size: 10pt; color: #333333; width:250 }

-->

</style>

<body leftmargin="0" topmargin="0" rightmargin="0">

<%session.LCID = 1046%>

</head>

<body>

<p style="margin-left: 30px; margin-right: 6" align="left"><%

If Not IsEmpty(Request.Form) Then

strMsg = "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0 Transitional//EN'>"

strMsg = strMsg & "<HTML><HEAD>"

strMsg = strMsg & "<META content='text/html; charset=iso-8859-1' http-equiv=Content-Type>"

strMsg = strMsg & "<META content='MSHTML 5.00.2614.3500' name=GENERATOR></HEAD>"

strMsg = strMsg & "<BODY><FONT face=12px size=2><B>" & cabecalho_email & "</B><BR><BR>"

strMsg = strMsg & "<B>Nome</B><BR><BR>" & Trim(Request.Form("Campo1")) & "<HR size=1 color=gainsboro>"

strMsg = strMsg & "<B>Telefone</B><BR><BR>" & Trim(Request.Form("Campo4")) &" - " & Trim(Request.Form("Campo44")) &"<HR size=1 color=gainsboro>"

strMsg = strMsg & "<B>e-mail</B><BR><BR>" & Trim(Request.Form("Campo2")) & "<HR size=1 color=gainsboro>"

strMsg = strMsg & "<B>Mensagem</B><BR><BR>" & Trim(Request.Form("Campo3")) & "<HR size=1 color=gainsboro>"

strMsg = strMsg & "</FONT></BOBY>"

strMsg = strMsg & "</HTML>"

nomeenvia = request.form("campo1")

emailenvia = request.form("campo2")

EnviaEmail servidor, componente, emailenvia, senha, nomeenvia, email_form, assunto_form, strMsg

Function EnviaEmail(Host,email_form,senha,Componente,Email,NomeEmail,ParaEmail,Assunto,Mensagem)

Select Case Componente

Case "CDOSYS"

On Error Resume Next

Set objCDOSYSMail = Server.CreateObject("CDO.Message")

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

objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1

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

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

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

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

objCDOSYSCon.Fields.update

'atualiza a configuração do CDOSYS para o envio do e-mail

Set objCDOSYSMail.Configuration = objCDOSYSCon

'e-mail do remetente

objCDOSYSMail.From = paraemail

'e-mail do destinatário

objCDOSYSMail.To = paraemail

objCDOSYSMail.Subject = Assunto

objCDOSYSMail.HtmlBody = Mensagem

'objCDOSYSMail.TextBody = "teste mensagem"

'objCDOSYSMail.fields.update

objCDOSYSMail.Send

Set objCDOSYSMail = Nothing

Set objCDOSYSCon = Nothing

End Select

End Function

%> <font face="Arial" color="#666666" size="2">Dados enviados </font></p>

<p style="margin-left: 30px; margin-right: 6" align="left">

<font face="Arial" color="#666666" size="2"><br>

Obrigado pelo contato ! Em breve estaremos retornando.</font></p>

<p style="margin-left: 6; margin-right: 6" align="left">

<font face="Arial" color="#666666" size="2"> </font></p>

<p style="margin-left: 6; margin-right: 6" align="left">

<font face="Arial" color="#666666" size="2">  </font></p>

<p></p>

<p style="word-spacing: 0; margin-left: 6; margin-right: 6; margin-top: 0; margin-bottom: 0" align="left">

<font face="Arial" color="#666666" size="2"><%

Else

%> </font></p>

<p style="word-spacing: 0; margin-top: 0; margin-bottom: 0" align="left"> 

</p>

<form name="form_incluir" method="post" onsubmit="return valida_pega()" action="<%=Request.ServerVariables("SCRIPT_NAME")%>" >

<div align="center">

<table border="0" cellpadding="2" cellspacing="1" class="tabela_formulario" width="50%">

<tr class="titulo_campos">

<td width="100%" align="left">

<p style="margin-left: 30px" align="left">Nome*<br>

<input type="text" name="Campo1" maxlength="50" df_verificar="sim" class="campos_formulario" size="50" style="border:1px solid #808080; padding-left:3px; padding-right:3px; padding-top:10px; padding-bottom:10px">

</td>

</tr>

<tr class="titulo_campos">

<td width="100%" align="left">

<p style="margin-left: 30px">Telefone* (ex. 11-9999-9999)<br>

<input type="text" id="Campo4" name="Campo4" maxlength="12" df_verificar="sim" class="campos_formulario" size="50" style="border:1px solid #808080; padding-left:3px; padding-right:3px; padding-top:10px; padding-bottom:10px">

</td>

</tr>

<tr class="titulo_campos">

<td width="100%" align="left">

<p style="margin-left: 30px">Celular* (ex. 11-9999-9999)<br>

<input type="text" id="Campo44" name="Campo44" maxlength="12" df_verificar="sim" class="campos_formulario" size="50" style="border:1px solid #808080; padding-left:3px; padding-right:3px; padding-top:10px; padding-bottom:10px">

</td>

</tr>

<tr class="titulo_campos">

<td width="100%" align="left">

<p style="margin-left: 30px">e-mail*<br>

<input name="Campo2" id="emailInput" onblur="return RegexEmail('emailInput')" class="campos_formulario" size="50" style="border:1px solid #808080; padding-left:3px; padding-right:3px; padding-top:10px; padding-bottom:10px">

</td>

</tr>

<tr class="titulo_campos">

<td width="100%" align="left">

<p style="margin-left: 30px">Mensagem*<br>

<textarea name="Campo3" df_verificar="sim" onkeypress="desabilita_cor(this)" class="campos_formulario" rows="7" cols="49" style="border:1px solid #808080; padding-left:3px; padding-right:3px; padding-top:10px; padding-bottom:10px; width:430"></textarea>

</td>

</tr>

<tr class="titulo_campos">

<td width="100%" align="left">

<table border="0" cellspacing="1" width="50%">

<tr>

<td>

<p align="center" style="margin-left: 130px">

<input type="submit" align="left" name="submit" value="Enviar" class="botao_enviar" style="width: 180; font-size: 15; font-family: Arial; border: 1px solid #DFDFDF; padding-left: 3px; padding-right: 3px; padding-top: 10px; padding-bottom: 10px; background-color: #E6E6E6">

</p>

</td>

</tr>

</table>

</td>

</tr>

</table>

</div>

</form>

<font color="#606060"><%

End If

%> </font>

</body>

</body>

</html>

</html>

Edited by Fabian Kulmann
Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

vou lhe enviar um exemplo funcional usado por mim:

Set objCDOSYSMail = Server.CreateObject("CDO.Message")
Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration")
Set Flds = objCDOSYSCon.Fields
Flds.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = [i]1[/i]
Flds.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = [i]EmailUsername[/i]
Flds.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = [i]EmailPassword [/i]
Flds.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = [i]EmailServer[/i]
Flds.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = [i]EmailPort[/i]
Flds.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = [i]2[/i]
Flds.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = [i]60[/i] 
Flds.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = [i]False[/i]
Flds.update

Set objCDOSYSMail.Configuration = objCDOSYSCon
objCDOSYSMail.From = [i]SiteEmail[/i]
objCDOSYSMail.To = [i]Email[/i]
objCDOSYSMail.Subject = [i]Asunto[/i]
objCDOSYSMail.HTMLBody = [i]htmlBody[/i]
objCDOSYSMail.Send 
Set objCDOSYSMail = Nothing
Set objCDOSYSCon = Nothing

---

Aguardo contato..

Link to comment
Share on other sites

  • 0
1980coelho posta o código completo com o preenchimento das váriaveis...

bom vou postar o codico da pagina completa que uso para senha perdida, arquivo: lostpassword.asp quanquer duvida de string ou variavel eu ajudo..

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title></title>

<!--#include file="adm_info.inc"-->

<!--#include file="md5.asp"-->

<!--#include file="settings.asp"-->

<style TYPE="text/css">

body {

background: url(images/_login.png) no-repeat;

background-size: 100%;

}

</style>

&lt;script language="javascript">

function TheFormCheck()

{

if (document.Login.txtUserName.value=="")

{

alert("Usuário está em branco. Por favor, digite.");

document.Login.txtUserName.focus();

return false;

}

}

</script>

</head><body>

<center>

<div style="border:0px solid; text-align:left; width:527px; height:246px; z-index:1; margin-top:120px; margin-left:0px;">

<div style="position:absolute; border:0px solid; width:100px; height:100px; z-index:2; margin-top:30px; margin-left:405px; background-image:url(images/qr.png); background-repeat:no-repeat; background-size:100%;">

</div>

<div style="position:absolute; border:0px solid; width:360px; height:203px; z-index:2; margin-top:20px; margin-left:20px;">

<table border="0">

<tr><td>

<b>Recuperar Senha </b>

</td></tr>

</table>

<p>

<table border="0">

<form name="login" method="post" action="password.asp?mode=get" onSubmit="return TheFormCheck()">

<tr><td>

Usuário: </td><td><input type='text' name='txtUserName'>

</td></tr>

<tr><td>

<img src='images/dot.png' width="1px" height="23px">

</td></tr>

<tr><td>

<input type="image" src="images/forward.png" name="Submit" value="" alt="">

</td></tr>

</form>

</table>

<p>

<table border="0">

<tr><td>

<%

Function RandomPW(myLength)

Const minLength = 6

Const maxLength = 20

Dim X, Y, strPW

If myLength = 0 Then

Randomize

myLength = Int((maxLength * Rnd) + minLength)

End If

For X = 1 To myLength

Y = Int((3 * Rnd) + 1) '(1) Numeric, (2) Uppercase, (3) Lowercase

Select Case Y

Case 1

Randomize

strPW = strPW & CHR(Int((9 * Rnd) + 48))

Case 2

Randomize

strPW = strPW & CHR(Int((25 * Rnd) + 65))

Case 3

Randomize

strPW = strPW & CHR(Int((25 * Rnd) + 97))

End Select

Next

RandomPW = strPW

End Function

If Request.querystring("mode") = "get" Then

strUserName = Replace(Request.Form("txtUserName"), "'", "''")

Set rsGetPassword = Server.CreateObject("ADODB.Recordset")

strSQL = "SELECT [username], [password], FROM tblUsers where username = '" & strUserName & "'"

rsGetPassword.Open strSQL, adoCon

If rsGetPassword.EOF Then

Response.Write ("<table border=1>")

Response.Write ("<tr><td>")

Response.Write ("<font color=red>Usuário inexistente.</font>")

Response.Write ("</td></tr>")

Response.Write ("</table>")

Else

strEmail = rsGetPassword("Email")

strPassword = RandomPW(0)

htmlBody = "Email enviado por ter solicitado a op&ccedil;&atilde;o ''<b>Recuperar Senha</b>'', se n&atilde;o solicitou esta, entre em contato com o administrador do site."

htmlBody = htmlBody & "<br><br>"

htmlBody = htmlBody & "Senha nova: <font color='red'>" & strPassword

htmlBody = htmlBody & "</font>"

htmlBody = htmlBody & "<br><br>"

htmlBody = htmlBody & "Voc&ecirc; pode, alterar essa senha atrav&eacute;s da p&aacute;gina, &aacute;rea de administra&ccedil;&atilde;o do site. Se tiver alguma dificuldade entre em contato."

htmlBody = htmlBody & "<br><br>"

htmlBody = htmlBody & "Obrigado,"

htmlBody = htmlBody & "<br>"

htmlBody = htmlBody & vSiteName

htmlBody = htmlBody & "<br><br>"

htmlBody = htmlBody & "---"

Set objCDOSYSMail = Server.CreateObject("CDO.Message")

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

Set Flds = objCDOSYSCon.Fields

Flds.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1

Flds.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = vEmailUsername

Flds.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = vEmailPassword

Flds.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = vEmailServer

Flds.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = vEmailPort

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

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

Flds.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False

Flds.update

Set objCDOSYSMail.Configuration = objCDOSYSCon

objCDOSYSMail.From = vSiteEmail

objCDOSYSMail.To = rsGetPassword("email")

objCDOSYSMail.Subject = "Solicitação de senha, site: " & vSiteName

objCDOSYSMail.HTMLBody = htmlBody

objCDOSYSMail.Send

Set objCDOSYSMail = Nothing

Set objCDOSYSCon = Nothing

strEPassword = md5(strPassword)

strUpdateSQL = "UPDATE tblUsers SET tblUsers.password='" & strEPassword & "' WHERE username ='" & strUserName & "'"

adoCon.Execute(strUpdateSQL)

Set rsGetPassword = Nothing

Set adoCon = Nothing

Response.Write ("<table border=1>")

Response.Write ("<tr><td>")

Response.Write ("Senha enviada ao Email do seu perfil.")

Response.Write ("</td></tr>")

Response.Write ("<tr><td>")

Response.Write ("<a href=login.asp><img src='images/back.png' border='0' alt=''></a>")

Response.Write ("</td></tr>")

Response.Write ("</table>")

End If

End If

%>

</td></tr>

</table>

</div>

</div>

</center>

</body>

</html>

Edited by 1980coelho
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...