Ver Mensaje Individual
  #6 (permalink)  
Antiguo 04/12/2007, 13:12
Oscar Correa
 
Fecha de Ingreso: agosto-2005
Mensajes: 4
Antigüedad: 19 años, 8 meses
Puntos: 0
Re: Un envio a un email

Puedes usar el CDO como función y utilizarlo cuantas veces lo quieras .

function sendemail(toemail,subject,mensaje,smtpserver,conta ctemail,passemail)


NewLine = chr(13) & chr(10)




//Primero definimos algunas variables
Dim MyBody,sFrom, x , NewLine , urlmicrosoft
strErr = ""
NewLine = chr(13) & chr(10)
MyBody = ""

//en las siguientes tres lineas reemplace lo que esta en maysculas y color marrn por su informacion particular
//adicionalmente no olvide cambiar el URL en la penultima linea de este script.

smtpserver = smtpserver
youremail = contactemail
yourpassword = passemail

//Ahora colocamos la informacion adicional
Dim iMsg
Set iMsg = CreateObject("CDO.Message")

//Configuracion del servidor SMTP.

urlmicrosoft = "http://schemas.microsoft.com/cdo/configuration/"
iMsg.Configuration.Fields.Item (urlmicrosoft & "sendusing") = 2
iMsg.Configuration.Fields.Item (urlmicrosoft & "smtpserver") = smtpserver
iMsg.Configuration.Fields.Item (urlmicrosoft & "smtpserverport") = 25
iMsg.Configuration.Fields.Item (urlmicrosoft & "smtpusessl") = False
iMsg.Configuration.Fields.Item (urlmicrosoft & "smtpconnectiontimeout") = 60

//basic (clear-text) authentication
iMsg.Configuration.Fields.Item (urlmicrosoft & "smtpauthenticate") = 1
iMsg.Configuration.Fields.Item (urlmicrosoft & "sendusername") = youremail
iMsg.Configuration.Fields.Item (urlmicrosoft & "sendpassword") = yourpassword

iMsg.Configuration.Fields.Update
//End remote SMTP server configuration section==

iMsg.To = toemail
iMsg.Subject = subject
iMsg.From = youremail
iMsg.Sender = youremail
//iMsg.Bcc = "[email protected]" - copia de carbon
//iMsg.Cc = "[email protected]" - copia
//iMsg.TextBody = MyBody
iMsg.HTMLBody = mensaje
On Error Resume Next ' catch errors'
iMsg.Send
if Err <> 0 Then ' error occurred'
sendemail = Err.Description
else
sendemail = "ok"
End if


Set iMsg = Nothing
End function



y para enviarlo

mensaje = "test"
toemail = "[email protected]"
toemail = correodelcliente
subject = "hola"
smtpserver = tusmtp
contactemail = tucorreo
passemail = tucontraseña
repuesta = sendemail(toemail,subject,mensaje,smtpserver,conta ctemail,passemail)

respuesta te muesta ok si funciona o el error


Puedes recibir las varibles por request y armar el mensaje que te va a llegar