-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenviar_correo.asp
127 lines (96 loc) · 3.86 KB
/
enviar_correo.asp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<%
dim db
Dim objUpload 'stores an Upload control object
Dim objEmail 'stores a Mailer control object
Dim strPath 'stores path to a directory we create at same level as this ASP page
dim autor
dim opcion
'The SendMail function will throw an exception if the operation is
' unsuccessful, so we enable inline error trapping
On Error Resume Next
Set objUpload = Server.CreateObject("Dundas.Upload")
Set oMail = Server.CreateObject("CDONTS.NewMail")
set db = server.CreateObject("SQLComandos.Comandos")
oMail.BodyFormat = 0
oMail.MailFormat = 0
'create a directory at same level as this ASP page
'this directory is used to store the uploaded files (which are renamed with a GUID preceding
'the original filename)
'NOTE: to delete these files you would have to use the ImpersonateUser method of
'the Upload control since the IUSR_ account SHOULD NOT have permission to delete files
objUpload.DirectoryCreate "\aecys\paecycod\temp"
'save the uploaded files. THIS POPULATES THE UPLOAD CONTROL'S COLLECTIONS!
autor = objUpload.Form("autor")
Response.Write autor
objUpload.Save strPath
copia = objUpload.Form("copia")
'especifica la dirección a la que se enviara una copia
oMail.Cc = copia
'especifica el tema del mensaje
tema = objUpload.Form("tema")
oMail.Subject = tema
'especifica el remitente del correo
'objEmail.FromAddress = "[email protected]"
oMail.From = "[email protected]"
'specify an SMTP Relay server. This increases the speed and reliability of the operation
'objEmail.SMTPRelayServers.Add "SomeSmtpServer.com"
'initialize the HtmlBody property, we'll throw a header into it
contenido = objUpload.Form("contenido")
Response.Write contenido
HTMLBody = "<Html><Head></Head><Body><H2>" & contenido
For Each Item in objUpload.Files
'verifica que el campo del archivo sea el valido
If (Item.TagName = "txtarchivo") Then
'If InStr(1,Item.ContentType,"audio") Then
'objEmail.HtmlEmbeddedObjs.Add Item.Path, 1, Item.OriginalPath
oMail.AttachFile (Item.Path)
'objEmail.HtmlBody = objEmail.HtmlBody & "<a href=cid:1>Docu</a>"
HTMLBody = HTMLBody & "<a href=cid:1>Documento</a>"
'End If
End If
If (Item.TagName = "txtImage") Then
If InStr(1,Item.ContentType,"image") Then
'objEmail.HtmlEmbeddedObjs.Add Item.Path, 2, Item.OriginalPath
oMail.AttachFile (Item.Path)
'objEmail.HtmlBody = objEmail.HtmlBody & "<IMG SRC=cid:2>"
HTMLBody = HTMLBody & "<IMG SRC=cid:2>"
End If
End If
Next
'terminar html body colocando las etiquetas html finales
'objEmail.HTMLBody = objEmail.HTMLBody & "</body></html>"
HTMLBody = HTMLBody & "</body></html>"
oMail.Body = HTMLBody
destino = objUpload.Form("lstus")
sql = "select mail from usuario where id in (" & destino & ") and recibir mail = 1"
set rs = db.SQLSelect("DBBAECYS",sql)
Response.Write sql
Response.End
if not rs.eof then
while rs.eof <> true
correo = rs("mail")
'especifica el destinatario del mensaje
response.write correo
'objEmail.TOs.Add correo
'objEmail.SendMail
'Prueba El exito/fallo
If Err.Number <> 0 Then
Response.Write "No se pudo enviar el mensaje, el siguiente error ocurrio: " & Err.Description
'Response.Redirect ("previewforo.asp?desc="&"No se pudo enviar el mensaje, el siguiente error ocurrio: " & Err.Description)
Else
'Exito
Response.Write "The correo html fue enviado exitosamente."
'Response.Redirect ("previewforo.asp?desc="&"The correo html fue enviado exitosamente.")
End If
rs.movenext
wend
end if
set rs = nothing
'enviar el correo'Response.Write "aqui<br>" 'Response.Write tema'Response.Write contenido'Response.Write objEmail.HTMLBody
Response.Redirect ("previewforo.asp?desc="&objEmail.HTMLBody)
'Response.End
'Liberar recursos
Set oMail = Nothing
Set objUpload = Nothing
set db = nothing
%>