Como criar formulários Em ASP Envio de e-mail Para criar um formulário com a linguagem ASP e enviar os dados via e-mail, utilize os exe...
Como criar formulários Em ASP
Envio de e-mail
Para criar um formulário com a linguagem ASP e enviar os dados via e-mail, utilize os exemplos abaixo:
<form method="POST" action="chillimail.asp">
<p>ChilliMail - Envio de E-mail através de página Web</p>
<table border="0" cellspacing="0" cellpadding="5">
<tr>
<td width="14%">Seu Email :</td>
<td width="86%"><input type="text" name="email" size="20"></td>
</tr>
<tr>
<td width="14%">Assunto :</td>
<td width="86%"><input type="text" name="assunto" size="20"></td>
</tr>
<tr>
<td width="14%">Mensagem :</td>
<td width="86%"><textarea rows="2" name="mensagem" cols="20"></textarea></td>
</tr>
<tr>
<td width="14%"></td>
<td width="86%"><input type="submit" value="enviar" name="botao"></td>
</tr>
</table>
</form>
<p>ChilliMail - Envio de E-mail através de página Web</p>
<table border="0" cellspacing="0" cellpadding="5">
<tr>
<td width="14%">Seu Email :</td>
<td width="86%"><input type="text" name="email" size="20"></td>
</tr>
<tr>
<td width="14%">Assunto :</td>
<td width="86%"><input type="text" name="assunto" size="20"></td>
</tr>
<tr>
<td width="14%">Mensagem :</td>
<td width="86%"><textarea rows="2" name="mensagem" cols="20"></textarea></td>
</tr>
<tr>
<td width="14%"></td>
<td width="86%"><input type="submit" value="enviar" name="botao"></td>
</tr>
</table>
</form>
Os comandos acima criam um formulário como o seguinte:
ChilliMail - Envio de E-mail através de página Web
Agora é necessário criar o arquivos "chillimail.asp" que enviará os dados e dará a resposta de que foram enviados com sucesso. Para isso utilize o código abaixo:
<%@LANGUAGE="VBSCRIPT"%>
<% Set
mailmsg = Server.CreateObject("CDONTS.NewMail")
mailmsg.To = "seuemail@seudominio.com.br"
mailmsg.From = request.form("email")
mailmsg.Subject = request.form("assunto")
mailmsg.Body = request.form("mensagem")
mailmsg.Host = "smtp.insite.com.br"
mailmsg.Send
%>
<html>
<head>
<title>formulário</title>
<meta http-equiv="Content-type" content="text/html; charset=iso-8859-1">
</head>
Agradecemos o contato!
<body bgcolor="#FFFFFF" text="#000000">
</body>
</html>
<% Set
mailmsg = Server.CreateObject("CDONTS.NewMail")
mailmsg.To = "seuemail@seudominio.com.br"
mailmsg.From = request.form("email")
mailmsg.Subject = request.form("assunto")
mailmsg.Body = request.form("mensagem")
mailmsg.Host = "smtp.insite.com.br"
mailmsg.Send
%>
<html>
<head>
<title>formulário</title>
<meta http-equiv="Content-type" content="text/html; charset=iso-8859-1">
</head>
Agradecemos o contato!
<body bgcolor="#FFFFFF" text="#000000">
</body>
</html>
Upload de arquivos
Para criar um formulário de upload de arquivos em ASP, siga o exemplo abaixo:
<html>
<head>
<title>Exemplo de ChilliUpload - Insite Solucoes Internet</title>
<meta http-equiv="Content-type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p>Enviar arquivo</p>
<form ACTION="admin_cast_upload.asp" METHOD="POST" ENCtype="multipart/form-data">
<input type="FILE" NAME="FILE">
<input type="SUBMIT" VALUE="Send">
</form>
</body>
</html>
<head>
<title>Exemplo de ChilliUpload - Insite Solucoes Internet</title>
<meta http-equiv="Content-type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p>Enviar arquivo</p>
<form ACTION="admin_cast_upload.asp" METHOD="POST" ENCtype="multipart/form-data">
<input type="FILE" NAME="FILE">
<input type="SUBMIT" VALUE="Send">
</form>
</body>
</html>
O código acima cria o seguinte formulário:
Enviar arquivo
|
É necessário criar também o arquivo "upload.asp", para isso utilize o exemplo abaixo:
<%@LANGUAGE="VBSCRIPT"%>
<%
Response.Expires = 0
Set upl = Server.CreateObject("Chili.Upload.1")
dim strSentence, arrWords, strOneWord, element
strSentence =upl.SourceFileName
strSentence = Trim(strSentence)
arrWords = Split (strSentence, "\", -1, 1)
element = UBound(arrWords)
Response.Write("Element = ")
Response.Write(element)
Response.Write("<BR>")
Response.Write(arrWords(element))
Response.Write("<BR>")
upl.SizeLimit ="30000"
upl.SaveToFile("/virtual/seudominio.com.br/www/" & arrWords(element))
%>
<html>
<head>
<title>Exemplo de Chilliupload - Insite Solucoes Internet</title>
<meta http-equiv="Content-type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
</body>
</html>
<%
Response.Expires = 0
Set upl = Server.CreateObject("Chili.Upload.1")
dim strSentence, arrWords, strOneWord, element
strSentence =upl.SourceFileName
strSentence = Trim(strSentence)
arrWords = Split (strSentence, "\", -1, 1)
element = UBound(arrWords)
Response.Write("Element = ")
Response.Write(element)
Response.Write("<BR>")
Response.Write(arrWords(element))
Response.Write("<BR>")
upl.SizeLimit ="30000"
upl.SaveToFile("/virtual/seudominio.com.br/www/" & arrWords(element))
%>
<html>
<head>
<title>Exemplo de Chilliupload - Insite Solucoes Internet</title>
<meta http-equiv="Content-type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
</body>
</html>
Variáveis de ambiente
Para verificar quais as variáveis que o servidor pode retornar para os seus scripts, você pode utilizar o script abaixo:
<TABLE>
<TR>
<TH>Server Variable</TH>
<TH>Value</TH>
</TR>
<% for each name in Request.ServerVariables %>
<TR>
<TD><%= name %></TD>
<TD><%= Request.ServerVariables(name) %></TD>
</TR>
<% Next %>
</TABLE>
<TR>
<TH>Server Variable</TH>
<TH>Value</TH>
</TR>
<% for each name in Request.ServerVariables %>
<TR>
<TD><%= name %></TD>
<TD><%= Request.ServerVariables(name) %></TD>
</TR>
<% Next %>
</TABLE>