.NET Framework - Envio de Email por Outlook (avanzado)

Asked By RafaelPatioOrteg on 17-Sep-08 10:53 PM
Hay una parte del siguiente codigo que no funciona en VFP6 y es la del

TRY
...

CATCH TO loError
tcReturn = [Error: ] + STR(loError.ERRORNO) + CHR(13) + ;
[LineNo: ] + STR(loError.LINENO) + CHR(13) + ;
[Message: ] + loError.MESSAGE + CHR(13) + ;
[Procedure: ] + loError.PROCEDURE + CHR(13) + ;
[Details: ] + loError.DETAILS + CHR(13) + ;
[StackLevel: ] + STR(loError.STACKLEVEL) + CHR(13) + ;
[LineContents: ] + loError.LINECONTENTS
FINALLY
RELEASE loConfig, loMsg
STORE .NULL. TO loConfig, loMsg
ENDTRY


Ojala que alguien de ustedes me pueda ayudar a substituirla para que
funcione al 100% en VFP6

Gracias por su ayuda de antemano...


*******************************
*!* Example of using SendViaCDOSYS
*******************************
DIMENSION aryAttach(2)
aryAttach(1) = "C:\attachment1.txt" && change to an actual file that exists
on your computer
aryAttach(2) = "C:\attachment2.zip" && change to an actual file that exists
on your computer

LOCAL lcFrom, lcTo, lcSubject, lcBody, lcCC, lcBCC, lcMailServer,
lcUserName, lcPassword, llHTMLFormat, lcErrReturn

lcFrom = "someone@sommehost.com"
lcTo = "someone@sommehost.com"
lcSubject = "Hey Have You Tried VFP Email?"
*!* Sending the body in HTML format
llHTMLFormat = .T. && change to .F. to send plain text message
lcBody = "<a
href='http://www.sweetpotatosoftware.com/SPSBlog/default.aspx'>" + ;
lcCC = "someoneelse@anotherhost.com"
lcBCC = "myboss@bosshost.com"
lcMailServer = "mail.myhost.com" && my SMTP Server
lcUserName = "me@myhost.com" && my SMTP username
lcPassword = "My_PaSsWoRd" && my SMTP password

SendViaCDOSYS(@lcErrReturn, lcFrom, lcTo, lcSubject, lcBody, @aryAttach,
lcCC, lcBCC, lcMailServer, lcUserName, lcPassword, llHTMLFormat)

IF EMPTY(lcErrReturn)
MESSAGEBOX("'" + lcSubject + "' sent successfullly.", 64, "Send email via
CDOSYS")
ELSE
MESSAGEBOX("'" + lcSubject + "' failed to be sent.  Reason:" + CHR(13) +
lcErrReturn, 64, "Send email via CDOSYS")
ENDIF

*******************************************
PROCEDURE SendViaCDOSYS(tcReturn, tcFrom, tcTo, tcSubject, tcBody, taFiles,
tcCC, tcBCC, tcMailServer, tcUserName, tcPassword, tlHTMLFormat)
*******************************************
LOCAL lcSchema, loConfig, loMsg, loAtt, lnCountAttachments
TRY
lcSchema = "http://schemas.microsoft.com/cdo/configuration/"

loConfig = CREATEOBJECT("CDO.Configuration")

WITH loConfig.FIELDS
.ITEM(lcSchema + "smtpserverport") = 25 && SMTP Port
.ITEM(lcSchema + "sendusing") = 2 && Send it using port
.ITEM(lcSchema + "smtpserver") = tcMailServer && host of smtp server
.ITEM(lcSchema + "smtpauthenticate") = 1 && Authenticate
.ITEM(lcSchema + "sendusername") = tcUserName && Username
.ITEM(lcSchema + "sendpassword") = tcPassword && Password
.UPDATE
ENDWITH

loMsg = CREATEOBJECT ("CDO.Message")
loMsg.Configuration = loConfig
WITH loMsg
.FROM = tcFrom
.TO = tcTo
IF TYPE("tcCC") = "C"
.CC = tcCC
ENDIF
IF TYPE("tcBCC") = "C"
.BCC = tcBCC
ENDIF
.Subject = tcSubject
IF tlHTMLFormat
.HTMLBody = tcBody
ELSE
.TextBody = tcBody
ENDIF
IF TYPE("tafiles",1) = "A"
FOR lnCountAttachments = 1 TO ALEN(taFiles)
loAtt=.AddAttachment(taFiles(lnCountAttachments))
ENDFOR
ENDIF
.SEND()
ENDWITH

CATCH TO loError
tcReturn = [Error: ] + STR(loError.ERRORNO) + CHR(13) + ;
[LineNo: ] + STR(loError.LINENO) + CHR(13) + ;
[Message: ] + loError.MESSAGE + CHR(13) + ;
[Procedure: ] + loError.PROCEDURE + CHR(13) + ;
[Details: ] + loError.DETAILS + CHR(13) + ;
[StackLevel: ] + STR(loError.STACKLEVEL) + CHR(13) + ;
[LineContents: ] + loError.LINECONTENTS
FINALLY
RELEASE loConfig, loMsg
STORE .NULL. TO loConfig, loMsg
ENDTRY
ENDPROC




luismari replied on 18-Sep-08 07:06 AM
La estructura de captura de errores TRY .. CATCH ... FINALLY está disponible
a partir de VFP8 y superior.

En VFP6 solo quita esa estructura y si quieres capturar errores utiliza ON
ERROR


--
Luis María Guayán
Tucumán, Argentina
________________________________
SysOp de www.PortalFox.com
Microsoft Visual FoxPro MVP
________________________________
La palabra imposible solo figura
en el diccionario de los tontos



escribió en el mensaje de
noticias:8F1D4CAB-EE6F-41B4-B0A3-9D391D00CD99@microsoft.com...
RafaelPatioOrteg replied on 18-Sep-08 01:32 PM
Estimado Luis.-

Gracias por el TIP, ya lo hice y funciono perfecto....

Saludos.-