Problemas en el envío de emails
Publicado por David (5 intervenciones) el 03/09/2007 11:50:43
Hola a todos... Mi problema es el siguiente... he de programar un sistema de avisos por email a los clientes utilizando ASP. Yo siempre lo he hecho con el ASPEmail q funciona muy bien. Pero donde estoy ahora no quieren poner ese componente en el servidor. Dicen que con el MAPI se puede hacer y me han dado la funcion en un codigo.... pero mi problema es que no consigo que me funcione... a continuacion os pongo el codigo que me han pasado a ver si sabeis por donde pillarlo para que funcione... muchisimas gracias.
++++++++++++++++CODIGO+++++++++++++++
Public Sub SendMailPlus(Mostrar As Boolean, PerfilID As String, PerfilPassword As String, Destinatario As String, Optional Asunto As String, Optional Mensaje As String, Optional ArchivoAdjunto As String)
On Error GoTo CtrlErrores
With frminicio.MAPISession1
.UserName = PerfilID
.Password = PerfilPassword
.NewSession = True
.DownLoadMail = False ' o false si no deseas recibir
.SignOn
End With
With frminicio.MAPIMessages1
.SessionID = frminicio.MAPISession1.SessionID
.MsgIndex = -1 ' nuevo mensaje
.Compose
If Trim$(Destinatario) <> "" Then .RecipDisplayName = Destinatario
' .RecipAddress = Destinatario
If Trim$(Asunto) <> "" Then .MsgSubject = Asunto
If Trim$(Mensaje) <> "" Then .MsgNoteText = Mensaje
If ArchivoAdjunto <> "" Then
.AttachmentIndex = 0
.AttachmentPathName = ArchivoAdjunto
.AttachmentPosition = 0
.AttachmentType = 0
End If
' If Trim$(Destinatario) = "" Then .Show
.Send Mostrar
End With
' Cuando ya no tengas que enviar ningun mail más:
frminicio.MAPISession1.SignOff
Fin:
Screen.MousePointer = 0
DoEvents
Exit Sub
CtrlErrores:
Screen.MousePointer = 0
DoEvents
Select Case Err.Number
Case "32050" 'La sesion ya existe. La cerramos y empezamos de nuevo
frminicio.MAPISession1.SignOff
SendMailPlus Mostrar, PerfilID, PerfilPassword, Destinatario, Asunto, Mensaje, ArchivoAdjunto
Case "32001" 'Cancelado por el usuario
frminicio.MAPISession1.SignOff
Case Else
MsgBox "Error : " & Err.Number & vbCr & Err.Description & vbCr & "...al intentar generar el emailc...", vbCritical, "Envio de email"
End Select
Resume Fin
Resume
++++++++++++++++CODIGO+++++++++++++++
Public Sub SendMailPlus(Mostrar As Boolean, PerfilID As String, PerfilPassword As String, Destinatario As String, Optional Asunto As String, Optional Mensaje As String, Optional ArchivoAdjunto As String)
On Error GoTo CtrlErrores
With frminicio.MAPISession1
.UserName = PerfilID
.Password = PerfilPassword
.NewSession = True
.DownLoadMail = False ' o false si no deseas recibir
.SignOn
End With
With frminicio.MAPIMessages1
.SessionID = frminicio.MAPISession1.SessionID
.MsgIndex = -1 ' nuevo mensaje
.Compose
If Trim$(Destinatario) <> "" Then .RecipDisplayName = Destinatario
' .RecipAddress = Destinatario
If Trim$(Asunto) <> "" Then .MsgSubject = Asunto
If Trim$(Mensaje) <> "" Then .MsgNoteText = Mensaje
If ArchivoAdjunto <> "" Then
.AttachmentIndex = 0
.AttachmentPathName = ArchivoAdjunto
.AttachmentPosition = 0
.AttachmentType = 0
End If
' If Trim$(Destinatario) = "" Then .Show
.Send Mostrar
End With
' Cuando ya no tengas que enviar ningun mail más:
frminicio.MAPISession1.SignOff
Fin:
Screen.MousePointer = 0
DoEvents
Exit Sub
CtrlErrores:
Screen.MousePointer = 0
DoEvents
Select Case Err.Number
Case "32050" 'La sesion ya existe. La cerramos y empezamos de nuevo
frminicio.MAPISession1.SignOff
SendMailPlus Mostrar, PerfilID, PerfilPassword, Destinatario, Asunto, Mensaje, ArchivoAdjunto
Case "32001" 'Cancelado por el usuario
frminicio.MAPISession1.SignOff
Case Else
MsgBox "Error : " & Err.Number & vbCr & Err.Description & vbCr & "...al intentar generar el emailc...", vbCritical, "Envio de email"
End Select
Resume Fin
Resume
Valora esta pregunta


0