Enlaces Patrocinados : juegos Gratis Online | emoticonos y emoticones | Descargas Bittorrent | Recursos Web | Depurando.com | Peliculas Gratis
nuestro blog
Anuncia Aqui | Descargar Música | Fotos Famosos | Torrents |


Mandar mail con html en ASP


con este codigo que encontre en una web en ingles y me dedique a traducir los comentarios podremos mandar un mail con html
desde nuestro server con ASP



<%
' Declaramos Variables
Dim objCDO  ' Nuestro Objeto CDO 

Dim strTo   ' Variable para Cargar el MAil
Dim strFrom
Dim strSubject
Dim strBody

' Primero Tomamos el Valor del Mail destino y lo cargamos en strTo

strTo = Request.Form("to")

' lo mismo hacemos con Subjet y el body 

'***************************************
'aCTIVALOS EN CASO DE QUE MANDES POR MEDIO DE UN FORM
' strSubject = Request.Form("subject")
' strBody    = Request.Form("body")
'**************************************


'***********************************************************
' A PARTIR DE AQUI NO CAMBIAMOS NADA SOLO EL MAIL DE AL 
' CUAL SE VA A RESPONDER 
' TRADUCCION DE COMENTARIOS POR LUIS TOSCANO - CODIGOLANDIA.COM
'***********************************************************
strFrom = "User Name <user@domain.com>"

strSubject = "Sample HTML Email sent from ASP 101!"

' aQUI PODREMOS CARGAR UN TEXTO DEFULT EN EL CASI DE USAR DATOS DINAMICOS DESDE UN FORM

strBody = "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">" & vbCrLf _
        & "<html>" & vbCrLf _
        & "<head>" & vbCrLf _
        & " <title>Sample Message From ASP 101</title>" & vbCrLf _
        & " <meta http-equiv=Content-Type content=""text/html; charset=iso-8859-1"">" & vbCrLf _
        & "</head>" & vbCrLf _
        & "<body bgcolor=""#FFFFCC"">" & vbCrLf _
        & " <h2>Sample Message From ASP 101</h2>" & vbCrLf _
        & " <p>" & vbCrLf _
        & "  This message was sent from a sample at" & vbCrLf _
        & "  <a href=""http://www.asp101.com"">ASP 101</a>." & vbCrLf _
        & "  It is used to show people how to send HTML" & vbCrLf _
        & "  formatted email from an Active Server Page." & vbCrLf _
        & "  If you did not request this email yourself," & vbCrLf _
        & "  your address was entered by one of our" & vbCrLf _
        & "  visitors." & vbCrLf _
        & "  <strong>" & vbCrLf _
        & "  We do not store these e-mail addresses." & vbCrLf _
        & "  </strong>" & vbCrLf _
        & " </p>" & vbCrLf _
        & " <font size=""-1"">" & vbCrLf _
        & "  <p>Please address all concerns to webmaster@asp101.com.</p>" & vbCrLf _
        & "  <p>This message was sent to: " & strTo & "</p>" & vbCrLf _
        & " </font>" & vbCrLf _
        & "</body>" & vbCrLf _
        & "</html>" & vbCrLf

' CON LAS SIGUIENTES LINEAS FORMATEAMOS EL HTML SI LAS NECESITAMOS LAS HABILITAMOS 

'Response.Write "<pre>"
'Response.Write Server.HTMLEncode(strbody)
'Response.Write "</pre>"
'Response.End


' Ok... EMPEZAMOS A VALIDAR EL MAIL 

' AQUI VALIDAMOS SI EL MAIL ESTA BIEN ESCRITO CON UNA FUNCION CREADA PREVIAMENTE
' EN CASO DE QUE EL MAIL ESTE MAL ESCRITO SE QUEDA HAY

If strTo = "" Or Not IsValidEmail(strTo) Then
    %>
    <form action="<%= Request.ServerVariables("URL") %>" METHOD="post">
        Enter your e-mail address:<br />
        <input type="text" name="to" size="30" />
        <input type="submit" value="Send Mail!" />
    </form>
    <%
Else
    ' ENVIAMOS NUESTRO MENSAJE
    
    Set objCDO = Server.CreateObject("CDO.Message")
    With objCDO
        .To       = strTo
        .From     = strFrom
        .Subject  = strSubject
        .HtmlBody = strBody
        
        ' BEFORE YOU UNCOMMENT THIS CHANGE THE VALUE OF
        ' strFrom ABOVE!  IF YOU CAN'T FIND IT SEARCH FOR
        ' strFrom = "User Name <user@domain.com>"
        ' THANK YOU.
        '.Send
    End With
    Set objCDO = Nothing

    '==============================================================
    ' ESTO ES POR SI CORRES EN UN SERVER NT4
    '==============================================================
    'Set objCDO = Server.CreateObject("CDONTS.NewMail")
    'objCDO.From    = strFrom
    'objCDO.To      = strTo
    'objCDO.Subject = strSubject
    'objCDO.Body    = strBody
    '
    'objCDO.BodyFormat = 0 ' CdoBodyFormatHTML
    'objCDO.MailFormat = 0 ' CdoMailFormatMime
    '
    ''objCDO.Cc  = "user@domain.com;user@domain.com"
    ''objCDO.Bcc = "user@domain.com;user@domain.com"
    '
    '' Send the message!
    'objCDO.Send
    'Set objCDO = Nothing

    'Response.Write "Message sent to " & strTo & "!"
    Response.Write "Message ARE NO LONGER BEING SENT because of all the abuse the system was receiving!"
End If
%>


<% ' SOLO FUNCIONES DE MANEJO

'CON ESTA FUNCION VALIDAMOS EL MAIL VIENDO QUE ESTE BIEN ESCRITO

Function IsValidEmail(strEmail)
    Dim bIsValid
    bIsValid = True
    
    If Len(strEmail) < 5 Then
        bIsValid = False
    Else
        If Instr(1, strEmail, " ") <> 0 Then
            bIsValid = False
        Else
            If InStr(1, strEmail, "@", 1) < 2 Then
                bIsValid = False
            Else
                If InStrRev(strEmail, ".") < InStr(1, strEmail, "@", 1) + 2 Then
                    bIsValid = False
                End If
            End If
        End If
    End If

    IsValidEmail = bIsValid
End Function
%>



original desde : ASP101.com







Los Mas Visitados
Scripts
Manuales
Hosting
Publicidad
Gana Dinero
Firefox

toolbar powered by Conduit

PHP Mysql linux Creative Commons License Spam Poison web counter Seo monitor

commentariosweb@gmail.com
LanLandia Networks -> www.colombiaphp.net | www.flowbarranquilla.net | www.weboneando.com | www.macventas.com | contacto commentariosweb@gmail.com