Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Mails with Cdo
Message
 
To
07/05/2013 17:06:08
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Title:
Miscellaneous
Thread ID:
01572955
Message ID:
01573036
Views:
123
>My problemn is this: I'm trying to transform a report output in Vfp9 to a .htm file. This I do with the HTMLListener.
>
>
>LOCAL oHtml
>SET PATH TO (HOME() + "FFC") ADDITIVE
>oHtml = NEWOBJECT("HtmlListener","_reportlistener.vcx")
>oHtml.TargetFileName = "c:\caja\datos\Informe.htm"
>oHtml.QuietMode = .T.
>oHtml.xsltParameters = CREATEOBJECT("Collection")
>oHtml.xsltParameters.Add(6, "numberPrecision")
>oHtml.externalFileLocation = ".\images"
>oHtml.copyImageFilesToExternalFileLocation = .T.
>REPORT FORM total_xcuenta OBJECT oHtml
>
>
>I get the file "Informe.htm". If I click on it the explorer opens and there it is, my vfp report in it.
>
>Then I try to send a mail with my .htm file displayed in it.
>
>
>OCAL ceMailRemitente as String, cContrasena as String, cTitulo as String, cTexto as String
>ceMailRemitente = "olgagaya@GMAIL.com"
>cContrasena = "PaulaSunde"
>cTitulo = "Caja - Totales x cuenta === Período " + DTOC(thisform.txtFechaInicial.Value) + " - " + DTOC(thisform.txtFechaFinal.Value)
>cTexto = "tita 8"
>
>LOCAL cEsquema as String, oCDO as Object, oMsg as Object, oError as Object
>cEsquema = "http://schemas.microsoft.com/cdo/configuration/"
>
>TRY
>oCDO = CREATEOBJECT("CDO.Configuration")
>oMsg = CREATEOBJECT("CDO.Message")
>
>WITH oCDO.Fields
>DO CASE
>CASE "GMAIL" $ Upper(ceMailRemitente)
>.Item(cEsquema + "smtpserver") = "smtp.gmail.com"
>.Item(cEsquema + "smtpserverport") = 465
>.Item(cEsquema + "sendusing") = 2
>.Item(cEsquema + "smtpauthenticate") = .T.
>.Item(cEsquema + "smtpusessl") = .T.
>OTHERWISE
>WAIT WINDOW NOWAIT "No puedo enviar este e-mail. No conozco los parámetros necesarios del servidor de correo"
>ENDCASE
>
>.Item(cEsquema + "sendusername") = ceMailRemitente
>.Item(cEsquema + "sendpassword") = cContrasena
>.Update()
>ENDWITH
>
>WITH oMsg
>.Configuration = oCDO
>.From = "Olga Gaya " + ceMailRemitente
>.To = thisform.cDestinatarios
>.Subject = cTitulo
>
>.CreateMHTMLBody("file://c:\caja\datos\informe.htm", 0)
>
>.Fields.Update
>.Send()
>
>WAIT WINDOW NOWAIT 'Los eMails para ' + thisform.cNombres + ' fueron enviados exitosamente.'
>ENDWITH
>
>CATCH TO oError
>MESSAGEBOX("No pudieron enviarse los eMails" + CHR(13) + "Error Nº: " + TRANSFORM(oError.ErrorNo) + CHR(13) + "Mensaje: " + oError.Message)
>FINALLY
>ENDTRY
>
>
>And it works. Or almost. Because the page looses its format. Everything is placed on the left side.
>Do you know why the file is not displayed as originally?
>
>Thanks for any answer

When setting email html body you, probably, need to preserve formattings made in the report ("pre" - "/pre" tags)

See if this help:
http://www.w3schools.com/html/tryit.asp?filename=tryhtml_pre

Good Luck
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform