Índice
Tutoriales
>
ASP
> Email
Calificación del Código:
Promedio: 9, con 2 voto(s).
Titulo: Mail con muchos componentes
Categoria: Email
1539 visitas desde: 12/01/2005
Descripción: Para enviar correo con varios componentes desde CDONTS hasta ASPMAIL
Código
<% 'Componente de Envio mail_comp = "CDOSYS" 'Datos del mail ServerAddr = "mail.dominio.com" Sender = "usuario@dominio.com" Subject = "Mail enviado con " & mail_comp Recipients = "uncorreo@mail.com" Text = "Texto Normal, enviado por : " & mail_comp TextHTML = "
Texto HTML
y esto sin BOLD, enviado por : " & mail_comp & "" Select Case mail_comp Case "CDOSYS" Set oComMsg = Server.CreateObject("CDO.Configuration") Set oComSMTP = Server.CreateObject("CDO.Message") oComMsg.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 oComMsg.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = ServerAddr oComMsg.Fields.Update Set oComSMTP.Configuration = oComMsg oComSMTP.From = Sender 'oComSMTP.ReplyTo = replyTo oComSMTP.To = Recipients oComSMTP.Subject = Subject oComSMTP.TextBody = Text oComSMTP.HtmlBody = TextHTML On error resume next oComSMTP.Send If Err.Number <> 0 then Response.Write "Mail Failed: " & Err.Description & "." Else Response.Write "Mail Sent with:" & mail_comp End If Set oComSMTP = Nothing Case "JMAIL" Set oComSMTP = Server.CreateObject("JMail.SMTPMail") oComSMTP.Silent = true oComSMTP.ServerAddress = ServerAddr oComSMTP.Sender = Sender 'oComSMTP.ReplyTo = replyTo oComSMTP.Subject = Subject addrList = Split(Recipients, ",") for each addr in addrList oComSMTP.AddRecipient Trim(addr) next 'oComSMTP.ContentType = "text/html" oComSMTP.Body = Text oComSMTP.HTMLBody = TextHTML if not oComSMTP.Execute then SendMail = "Mail Failed, Error: " & mailObj.ErrorMessage & "." Else SendMail = "JMail enviado" end if Set oComSMTP = Nothing Response.Write SendMail Case "DUNDAS" Set oComSMTP = Server.CreateObject("Dundas.Mailer") oComSMTP.TOs.Add Recipients oComSMTP.Subject = Subject oComSMTP.FromAddress = Sender oComSMTP.SMTPRelayServers.Add ServerAddr oComSMTP.Body = Text oComSMTP.HTMLBody = TextHTML oComSMTP.SendMail If Err.Number <> 0 Then Response.Write "DUNDAS, Mail sent failed" Else Response.Write "DUNDAS, Mail Sent" End If Case "CDONTS" Set oComSMTP = Server.CreateObject("CDONTS.NewMail") oComSMTP.BodyFormat = 0 oComSMTP.MailFormat = 0 oComSMTP.From = Sender 'oComSMTP.Value("Reply-To") = replyTo oComSMTP.To = Recipients oComSMTP.Subject = Subject oComSMTP.Body = TextHTML oComSMTP.Send Response.Write "Mail enviado con CDONTS" Case "ASPMAIL" Set oComSMTP = Server.CreateObject("SMTPsvg.Mailer") BOUNDARY = "----xxxxxx" TEXT_HEADER = "--" & BOUNDARY & VBCrLf & "Content-Type: text/plain;" & VBCrLf & _ "Content-Transfer-Encoding: quoted-printable" & VBCrLf & VBCrLf HTML_HEADER = "--" & BOUNDARY & VBCrLf & "Content-Type: text/html;" & VBCrLf & _ "Content-Transfer-Encoding: quoted-printable" & VBCrLf & VBCrLf MP_FOOTER = "--" & BOUNDARY & "--" & VBCrLf strBody = TEXT_HEADER & Text & VBCrLf & HTML_HEADER & TextHTML & VBCrLf & MP_FOOTER oComSMTP.RemoteHost = ServerAddr 'oComSMTP.Username = Username ASPMAIL doesn´t support the authentication option right now. 'oComSMTP.Password = Password 'oComSMTP.LoginMethod = LoginMethod oComSMTP.FromAddress = Sender oComSMTP.FromName = "XXXXXXXXXXX" addrList = Split(Recipients, ";") for each addr in addrList oComSMTP.AddRecipient ".", Trim(addr) next 'oComSMTP.AddRecipient = Recipients oComSMTP.Subject = Subject oComSMTP.Text = strBody oComSMTP.ContentType = "multipart/alternative; boundary=""" & BOUNDARY & """" if oComSMTP.SendMail then Response.Write ("
Mail Sent") else Response.Write ("
Error: " & oComSMTP.Response) end if Set oComSMTP = Nothing Case "ASPEMAIL" Set oComSMTP = Server.CreateObject("Persits.MailSender") 'Variables Dim strErr oComSMTP.Host = ServerAddr oComSMTP.From = Sender oComSMTP.FromName = "XXXXXXXXXXXX" oComSMTP.AddAddress Recipients oComSMTP.Subject = Subject oComSMTP.Body = TextHTML oComSMTP.AltBody = Text 'oComSMTP.UserName = Username 'oComSMTP.Password = Password strErr = "" On Error Resume Next 'Catch Errors oComSMTP.Send 'Send Message If Err <> 0 Then 'Error strErr = Err.Description Response.Write "Error" & strErr Else Response.Write "Mail Sent" End If Case "FATH" End Select %>
Enviar a un amigo
Votar
Buscar