Foros del Web » Programando para Internet » ASP Clásico »

Envío de mails / attachments

Estas en el tema de Envío de mails / attachments en el foro de ASP Clásico en Foros del Web. Estimados Amigos: Debo activar para mis estudiantes un servicio de envío de mails y attachments (para sus trabajos). Alguien podría indicarme cómo quedaría este código ...
  #1 (permalink)  
Antiguo 28/04/2003, 15:36
Avatar de emajesus  
Fecha de Ingreso: abril-2003
Mensajes: 278
Antigüedad: 21 años, 1 mes
Puntos: 1
Envío de mails / attachments

Estimados Amigos:

Debo activar para mis estudiantes un servicio de envío de mails y attachments (para sus trabajos). Alguien podría indicarme cómo quedaría este código si desease enviar también attachments desde mi página. [Tengo alojada la página en Brinkster, opción X4].

Página Sendmail3.asp:

<%

'Declare local variables to hold the data from the Input form page that is used above.

Dim strTo
Dim strSubject
Dim strBody 'Strings for recipient, subject, boby
Dim objCDOMail 'The CDO object

'First we'll read in the values entered from the form into the Local variables
strFrom = Request.Form("From") 'Make sure the From field has no spaces.
strTo = Request.Form("to")
strSubject = Request.Form("subject")
strBody = Request.Form("body")

' Create an instance of the NewMail object.
Set objCDOMail = Server.CreateObject("CDONTS.NewMail")

' Set the properties of the object
objCDOMail.From = StrFrom
objCDOMail.To = strTo
objCDOMail.Subject = strSubject
objCDOMail.Body = strBody


' There are lots of other properties you can use.
' You can send HTML e-mail, attachments, etc...
' You can also modify most aspects of the message
' like importance, custom headers, ...
' Check the help files for a full list as well
' and the correct syntax.

' Some of the more useful ones I've included samples of here:
'objCDOMail.Cc = "mailto:[email protected]" Notice this sending to more than one person!
'objCDOMail.Bcc = "[email protected];[email protected]"
'objCDOMail.Importance = 1 '(0=Low, 1=Normal, 2=High)im a
'objCDOMail.AttachFile "c:\path\filename.txt", "filename.txt"

' Send the message!
objCDOMail.Send

' Set the object to nothing because it immediately becomes
' invalid after calling the Send method + it clears it out of the Server's Memory.
Set objCDOMail = Nothing
%>
<html>
<head><title>Sent Mail</title></head>
<body>
Your mail was sent to:<% = request("to") %><br>
The time that is was sent was: <% = Now %>

</body>
</html>

::::::::::::::::::::::::::::::::::

Página Html.htm:

<html>
<head><title>Mail Input Page</title></head>
<body>
<form method="post" action="sendmail3.asp" name="Inputform">
<table border="1" width="50%">
<tr><td width="48%">From</td>
<td width="52%">&nbsp;<input type="text" name="From" size="20"></td></tr>
<tr><td width="48%">To</td><td width="52%"><input type="text" name="to" size="20"></td></tr>
<tr><td width="48%">Subject</td><td width="52%"><input type="text" name="subject" size="20"></td></tr>
<tr><td width="48%">Body</td><td width="52%"><input type="text" name="body" size="20"></td></tr>
<tr><td width="48%"><input type="submit" value="Send" name="B1"><input type="reset"value="Reset" name="B2"></td>
<td width="52%">&nbsp;</td></tr>
</table>
</form>
</body>
</html>


Un saludo,

Emajesus
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 22:20.