Page 1 of 1

cuerpo de mensaje para hb_sendmail()

Posted: Tue Apr 13, 2021 5:48 pm
by edufloriv
Saludos amigos,

Tengo este código para enviar un correo automatizado:

Code: Select all

PROC DetectaStocksUV_Correo( aLista )

LOCAL cFecHoy       := DTOC(GetFecServ())
LOCAL cSubject      := 'Comparativo de stocks (almacén vs ventas) al '+DTOC(DATE())
LOCAL cBody         := ''
LOCAL cPopServer    := "mail.xxxxxxx.xxx.xx"
LOCAL cSMTPServer   := "mail.xxxxxxx.xxx.xx"
LOCAL cSMTPPassWord := "xxxxxxx"
LOCAL cFrom         := "xxxxx@xxxxx.xxx.xx"
LOCAL cUser         := "eflores"
LOCAL aTo           := {'xxxxx@xxxxx.xxx.xx'}
LOCAL aFiles        := {}
LOCAL cTab          := chr(9)

   MENSABAR('Enviando correo...')

   cBody := 'Los siguientes productos difieren en sus stocks de almacén y ventas:'+chr(13)+chr(10)+;
            REPL('=',100)+chr(13)+chr(10)+;
            'CODIGO' + ctab + 'PRODUCTO' + ctab + 'LABO' + ctab + 'STK.ALM.' + ctab + 'STK.VTA.' + chr(13) + chr(10)+;
            REPL('=',100)+chr(13)+chr(10)

   FOR nLst = 1 TO LEN(aLista)
      nOcup := LEN(aLista[nLst,2]) + 7
      nTab1 := INT( nOcup / 5 )
      nTab2 := 10 - nTab1
      cBody := cBody + ;
               aLista[nLst,1]           + '  ' + ;
               aLista[nLst,2]           + REPL(ctab,nTab2) + ;
               aLista[nLst,3]           + ctab + ;
               INTSTR( aLista[nLst,4] ) + ctab + ;
               INTSTR( aLista[nLst,5] ) + ctab + VALSTR(nOcup) + '  ' + VALSTR(nTab2) + chr(13) + chr(10)
   NEXT

   cBody := cBody +;
   REPL(chr(13)+chr(10),10)+;
   'SisComFar'+chr(13)+chr(10)

   lRespuesta := hb_SendMail( ;
                  cSMTPServer,;              // Servidor
                  25 ,;                      // Puerto
                  cFrom,;                    // From
                  aTo,;                      // To
                  NIL ,;                     /* CC */
                  NIL ,;                     /* BCC */
                  cBody ,;                   // Body
                  cSubject ,;                // Subject
                  aFiles ,;                  // aFiles attached
                  cFrom ,;                   // User   (obligatorio)
                  cSMTPPassword,;            // Pass (obligatorio)
                  cPopServer,;               // POP Server (obligatorio)
                  3 ,;                       /* nPriority */
                  .F. ,;                     /* lRead */
                  .F. ,;                     /* lTrace */
                  .T. ,;                     /* lPopAuth */
                  .F. ,;                     /* lNoAuth */
                  NIL ,;                     /* nTimeOut */
                  NIL ,;                     /* cReplyTo */
                  .F. ,;                     /* lTLS */
                  cSMTPPassWord )

   MENSABAR('...')

RETURN
Pero no logro hacer que el correo se vea bien, es decir, alineado en columnas:
correo-texto.png
correo-texto.png (121.5 KiB) Viewed 1250 times
Veo que hb_sendmail() no tiene opción para enviar el correo en formato HTML, por lo que no se como hacer para mejorar la presentación. Agradeceré cualquier sugerencia.


Reciban mis cordiales saludos.

Re: cuerpo de mensaje para hb_sendmail()

Posted: Tue Apr 13, 2021 6:35 pm
by danielmaximiliano
deberias rellenar de espacios flatantes en aLista[nLst... al momento de armar la cadena, en cadenas numericas ajustado a la derecha para que los decimales esten correctos.

Re: cuerpo de mensaje para hb_sendmail()

Posted: Tue Apr 13, 2021 8:33 pm
by Claudio Ricardo
Hola...
Entre Codigo y Producto quedan bien alineados con: aLista[nLst,1] + ' ' + ;
Puedes probar en vez de usar Chr (9) ( Tab ) a usar espacios con Space ( número de espacios )
Lo mejor es 1 y cambiar el valor en la fórmula para lograr más precisión en el cálculo y además
tener en cuenta que si es UTF hay que usar funciones tipo Hb_Ulen ()
Una vez me pasó algo similar y lo resolví así !

Re: cuerpo de mensaje para hb_sendmail()

Posted: Wed Apr 14, 2021 3:32 am
by AUGE_OHR
hi,

to send "formatted" ASCI Text you must use a "fixed" FONT where every Sign have same wide.

but why send Text and not a PDF as Attachment :idea:

c:\harbour\contrib\hbtip\tests\tipmmail.prg
tipmmail.zip
(1.07 KiB) Downloaded 85 times

Re: cuerpo de mensaje para hb_sendmail()

Posted: Wed Apr 14, 2021 11:49 pm
by jairpinho
edufloriv wrote: Tue Apr 13, 2021 5:48 pm Saludos amigos,

Tengo este código para enviar un correo automatizado:

Code: Select all

PROC DetectaStocksUV_Correo( aLista )

LOCAL cFecHoy       := DTOC(GetFecServ())
LOCAL cSubject      := 'Comparativo de stocks (almacén vs ventas) al '+DTOC(DATE())
LOCAL cBody         := ''
LOCAL cPopServer    := "mail.xxxxxxx.xxx.xx"
LOCAL cSMTPServer   := "mail.xxxxxxx.xxx.xx"
LOCAL cSMTPPassWord := "xxxxxxx"
LOCAL cFrom         := "xxxxx@xxxxx.xxx.xx"
LOCAL cUser         := "eflores"
LOCAL aTo           := {'xxxxx@xxxxx.xxx.xx'}
LOCAL aFiles        := {}
LOCAL cTab          := chr(9)

   MENSABAR('Enviando correo...')

   cBody := 'Los siguientes productos difieren en sus stocks de almacén y ventas:'+chr(13)+chr(10)+;
            REPL('=',100)+chr(13)+chr(10)+;
            'CODIGO' + ctab + 'PRODUCTO' + ctab + 'LABO' + ctab + 'STK.ALM.' + ctab + 'STK.VTA.' + chr(13) + chr(10)+;
            REPL('=',100)+chr(13)+chr(10)

   FOR nLst = 1 TO LEN(aLista)
      nOcup := LEN(aLista[nLst,2]) + 7
      nTab1 := INT( nOcup / 5 )
      nTab2 := 10 - nTab1
      cBody := cBody + ;
               aLista[nLst,1]           + '  ' + ;
               aLista[nLst,2]           + REPL(ctab,nTab2) + ;
               aLista[nLst,3]           + ctab + ;
               INTSTR( aLista[nLst,4] ) + ctab + ;
               INTSTR( aLista[nLst,5] ) + ctab + VALSTR(nOcup) + '  ' + VALSTR(nTab2) + chr(13) + chr(10)
   NEXT

   cBody := cBody +;
   REPL(chr(13)+chr(10),10)+;
   'SisComFar'+chr(13)+chr(10)

   lRespuesta := hb_SendMail( ;
                  cSMTPServer,;              // Servidor
                  25 ,;                      // Puerto
                  cFrom,;                    // From
                  aTo,;                      // To
                  NIL ,;                     /* CC */
                  NIL ,;                     /* BCC */
                  cBody ,;                   // Body
                  cSubject ,;                // Subject
                  aFiles ,;                  // aFiles attached
                  cFrom ,;                   // User   (obligatorio)
                  cSMTPPassword,;            // Pass (obligatorio)
                  cPopServer,;               // POP Server (obligatorio)
                  3 ,;                       /* nPriority */
                  .F. ,;                     /* lRead */
                  .F. ,;                     /* lTrace */
                  .T. ,;                     /* lPopAuth */
                  .F. ,;                     /* lNoAuth */
                  NIL ,;                     /* nTimeOut */
                  NIL ,;                     /* cReplyTo */
                  .F. ,;                     /* lTLS */
                  cSMTPPassWord )

   MENSABAR('...')

RETURN
Pero no logro hacer que el correo se vea bien, es decir, alineado en columnas:

correo-texto.png

Veo que hb_sendmail() no tiene opción para enviar el correo en formato HTML, por lo que no se como hacer para mejorar la presentación. Agradeceré cualquier sugerencia.


Reciban mis cordiales saludos.


ola tenta usar css

Code: Select all

#include <hmg.ch>
#include "common.ch"
#include "minigui.ch"
#include "hbclass.ch"

/*
		cAssunto   := "SOLICITAÇÃO COMPRAS Num.  " + cCod
 	
		oHTML := HB_THTML_CSS():New()
		//oHTML:SetTitle( "Harbour Power Demonstration" )
		oHTML:AddHead( "SOLICITAÇÃO COMPRAS Num. : " + cCod )
		oHTML:AddPara( "Requisitante : " + cNome_Req, "right" , 200 , .T.,,,, 4 )
		oHTML:AddPara( "Setor : " + cSetor_Req, "right" , 200 , .T.,,,, 4 , 2 )
		oHTML:AddPara( "Data da Solitação : " + cData1, "right" , 200 , .T.,,,, 4 )
		oHTML:AddPara( "Data de Aprovação : " + cData2, "right" , 200 , .T.,,,, 4 )
		oHTML:AddPara( "Data de Previsão : " + cData3, "right" , 200 , .T.,,,, 4 )
		oHTML:AddPara( "Data de Entrega : " + cData4, "right" , 200 , .T.,,,, 4)
		oHTML:AddPara( "Ordem de Compra : ", "right" , 200 , .T.,,,, 4 )
		oHTML:AddPara( "Maquina : ", "right" , 200 , .T.,,,, 4 )
		oHTML:AddPara( "Observação : ", "right" , 200 , .T.,,,, 4 )
		oHTML:AddPara( "por favor não responda este e-mail, ele serve apenas para comunicar a você e o solicitante de Manuteção.", "left" , 1000 , .T.,,,, 3.5 )
		oHTML:AddPara( "[MasterServ Manutenção]", "left" , 200 , .T. ,,,, 3.5)
		//oHTML:AddLink( "https://harbour.github.io", "Meet the Harbour power!" )
		oHTML:Generate(3) //Generate(nLineheight) line spacing
		//oHTML:ShowResult()
		oHTML:SaveToFile( "body.html" )	
		//cCorpoMsg2 := 	oHTML:ShowResult()	
*/


CREATE CLASS HB_THTML_CSS

   VAR cTitle                             // Page Title
   VAR cBody                             	// HTML Body Handler
   VAR cBGColor                           	// Background Color
   VAR cLinkColor                         	// Link Color
   VAR cvLinkColor                        	// Visited Link Color
   VAR cContent                           	// Page Content Handler

   METHOD New()                        		// New Method
   METHOD SetTitle( cTitle )              	// Set Page Title
   METHOD AddLink( cLinkTo, cLinkName )   		// Add <H1> Header
   METHOD AddHead( cDescr )               	// Add Hyperlink
   METHOD AddPara( cTag, cAlign )        	// Add Paragraph
   METHOD Generate()                      	// Generate HTML
   METHOD ShowResult()                    	// Saves Content to File
   METHOD SaveToFile( cFile )             	// Show Result

END CLASS

	METHOD New() CLASS HB_THTML_CSS

		   ::cTitle      	:= "Untitled"
		   ::cBGColor    	:= "#FFFFFF"
		   ::cLinkColor  	:= "#0000FF"
		   ::cvLinkColor 	:= "#FF0000"
		   ::cContent    	:= ""
		   ::cBody       	:= ""

	RETURN Self

	METHOD SetTitle( cTitle ) CLASS HB_THTML_CSS  // title de pagina doc.html

			::cTitle := txt2html(cTitle)

	RETURN Self

	METHOD AddLink( cLinkTo, cLinkName ) CLASS HB_THTML_CSS

			::cBody += "<a href='" + cLinkTo + "'>" + cLinkName + "</a>"

	RETURN Self

	METHOD AddHead( cDescr ) CLASS HB_THTML_CSS  // titulo de body(conteudo do texto)

		   // Why this doesn't work?
		   // ::cBody += ...
		   // ???

		   ::cBody += "<h1>" + txt2html(cDescr) + "</h1>"

		   RETURN NIL

	METHOD AddPara( cTag, cAlign, nWidth, lBold,lItalic,cColor,cFonte,nSize) CLASS HB_THTML_CSS
			hb_default( @cAlign, "Left" )
			hb_default( @nWidth, 300 )
			hb_default( @lBold, .F. )
			hb_default( @lItalic, .F. )
			hb_default( @cColor, "black" )
			hb_default(@cFonte, "Arial" )
			**hb_default(@cFonte, "Helvetica" )
			**hb_default(@cFonte,"Times New Roman")
			hb_default( @nSize, 2.5 )

 
			//"<p align='" + cAlign + "'>" + hb_eol() + ;
 
 			if lBold  == .T. .and. lItalic  == .F.
			//msgdebug("bold")
				cTexto := "<font color='"+ cColor + "'  face='"+ cFonte +"' size='"+ Alltrim(STR(nSize)) +"'px'<b>"+txt2html(cTag) +"</span></b></font>" + hb_eol()
			elseif lBold  == .F. .and. lItalic  == .T.
				cTexto := "<font color='"+ cColor + "'  face='"+ cFonte +"' size='"+ Alltrim(STR(nSize)) +"'px'<i>"+txt2html(cTag) +"</i></font>" + hb_eol()
			elseif lBold  == .T. .and. lItalic  == .T.
				cTexto := "<font color='"+ cColor + "'  face='"+ cFonte +"' size='"+ Alltrim(STR(nSize)) +"'px'<b><i>"+txt2html(cTag) +"</i></b></font>" + hb_eol()
			elseif lBold  == .F. .and. lItalic  == .F.	
				cTexto := txt2html(cTag) + hb_eol() 
			endif
 
 //<span style = 'line-height: 0.5'>
			::cBody += ;
			"<p class ='line_height' align='" + cAlign + "' style='width:"+ alltrim(str(nWidth)) +"px'>" + hb_eol() + ;
				cTexto +;
			"</p>"


	RETURN Self
//"+ Alltrim(str(nLine_height)) + "

/**

<div>
	<div style="float: left;width: 300;text-align: right;">Valor 1:</div>
	<div style="float: right;">Valor 2</div>
	<div style="clear: both;"></div>
</div>
*/

	METHOD Generate(nLineheight) CLASS HB_THTML_CSS
			hb_default( @nLineheight, 0.7 )
			//msgdebug(Alltrim(str(nLineheight)))
		::cContent := ;
			"<html><head><style>p.line_height {line-height:"+ Alltrim(str(nLineheight)) + "}</style>"	+ hb_eol() + ;
			"<title>" + ::cTitle + "</title>"                      							+ hb_eol() + ;
			"<body link='" + ::cLinkColor + "'" 											+;
			"vlink='" + ::cvLinkColor + "'>" 												+hb_eol() + ;
		::cBody                                        										+ hb_eol() + ;
			"</body></html>"

	RETURN Self

	METHOD ShowResult() CLASS HB_THTML_CSS

		   OutStd( ;
				;//      "HTTP/1.0 200 OK"                                     + hb_eol() + ;
			"CONTENT-TYPE: TEXT/HTML"                     				+ hb_eol() + hb_eol() + ;
			  ::cContent )

	RETURN Self

	METHOD SaveToFile( cFile ) CLASS HB_THTML_CSS

		   LOCAL hFile := FCreate( cFile )

		   FWrite( hFile, ::cContent )
		   FClose( hFile )

	RETURN Self
	
/**
		cAssunto   := "SOLICITAÇÃO COMPRAS Num.  " + cCod
 	
		oHTML := THtml():New()
		//oHTML:SetTitle( "Harbour Power Demonstration" )
		oHTML:AddHead( "SOLICITAÇÃO COMPRAS Num. : " + cCod )
		oHTML:AddPara( "Requisitante : " + cNome_Req, "right" , 200 , .T.,,,, 4, 0.8 )
		oHTML:AddPara( "Setor : " + cSetor_Req, "right" , 200 , .T.,,,, 4 , 0.8 )
		oHTML:AddPara( "Data da Solitação : " + cData1, "right" , 200 , .T.,,,, 4, 0.8)
		oHTML:AddPara( "Data de Aprovação : " + cData2, "right" , 200 , .T.,,,, 4 , 0.8)
		oHTML:AddPara( "Data de Previsão : " + cData3, "right" , 200 , .T.,,,, 4 , 0.8 )
		oHTML:AddPara( "Data de Entrega : " + cData4, "right" , 200 , .T.,,,, 4 , 0.8)
		oHTML:AddPara( "Ordem de Compra : ", "right" , 200 , .T.,,,, 4, 0.8)
		oHTML:AddPara( "Maquina : ", "right" , 200 , .T.,,,, 4, 0.8 )
		oHTML:AddPara( "Observação : ", "right" , 200 , .T.,,,, 4, 0.8 )
		oHTML:AddPara( "por favor não responda este e-mail, ele serve apenas para comunicar a você e o solicitante de Manuteção.", "left" , 1000 , .T.,,,, 3.5, 0.8)
		oHTML:AddPara( "[MasterServ Manutenção]", "left" , 200 , .T. ,,,, 3.5, 0.8)
		//oHTML:AddLink( "https://harbour.github.io", "Meet the Harbour power!" )
		oHTML:Generate() //Generate(nLineheight) line spacing
		//oHTML:ShowResult()
		oHTML:SaveToFile( "body.html" )	
		//cCorpoMsg2 := 	oHTML:ShowResult()
*/


*********************************
CREATE CLASS HB_THTML
************************************
   VAR cTitle                             // Page Title
   VAR cBody                             	// HTML Body Handler
   VAR cBGColor                           	// Background Color
   VAR cLinkColor                         	// Link Color
   VAR cvLinkColor                        	// Visited Link Color
   VAR cContent                           	// Page Content Handler

   METHOD New()                        	// New Method
   METHOD SetTitle( cTitle )              // Set Page Title
   METHOD AddLink( cLinkTo, cLinkName )   		// Add <H1> Header
   METHOD AddHead( cDescr )               	// Add Hyperlink
   METHOD AddPara( cTag,cAlign_Col1,cTexto, cAlign_Col2, nWidth, lBold,lItalic,cColor,cFonte,nSize,nLineheight )        	// Add Paragraph
   METHOD Generate()                      	// Generate HTML
   METHOD ShowResult()                    	// Saves Content to File
   METHOD SaveToFile( cFile )             	// Show Result

END CLASS


			METHOD New() CLASS HB_THTML

				   ::cTitle      	:= "Untitled"
				   ::cBGColor    	:= "#FFFFFF"
				   ::cLinkColor  	:= "#0000FF"
				   ::cvLinkColor 	:= "#FF0000"
				   ::cContent    	:= ""
				   ::cBody       	:= ""

			RETURN Self

			METHOD SetTitle( cTitle ) CLASS HB_THTML  // title de pagina doc.html

					::cTitle := txt2html(cTitle)

			RETURN Self

			METHOD AddLink( cLinkTo, cLinkName ) CLASS HB_THTML

					::cBody += "<a href='" + cLinkTo + "'>" + cLinkName + "</a>"

			RETURN Self

			METHOD AddHead( cDescr ) CLASS HB_THTML  // titulo de body(conteudo do texto)

		   // Why this doesn't work?
		   // ::cBody += ...
		   // ???

		   ::cBody += "<h1>" + txt2html(cDescr) + "</h1>"

		   RETURN NIL

			METHOD AddPara( cTag,cAlign_Col1,cTexto, cAlign_Col2, nWidth, lBold,lItalic,cColor,cFonte,nSize,nLineheight) CLASS HB_THTML
			hb_default( @cAlign_Col1, "right" )
			hb_default( @cAlign_Col2, "Left" )
			hb_default( @nWidth, 300 )
			hb_default( @lBold, .F. )
			hb_default( @lItalic, .F. )
			hb_default( @cColor, "black" )
			**hb_default(@cFonte, "Arial" )
			hb_default(@cFonte, "Helvetica" )
			**hb_default(@cFonte,"Times New Roman")
			hb_default( @nSize, 5 )
 			hb_default( @nLineheight, 0.7 )
			hb_default( @cTexto, "" )
			//"<p align='" + cAlign + "'>" + hb_eol() + ;
 
 			if lBold  == .T. .and. lItalic  == .F.
				cTag_Form := "<font color='"+ cColor + "'  face='"+ cFonte +"' size='"+ Alltrim(STR(nSize)) +"'px'<b>"+txt2html(cTag) +"</b></font>" + hb_eol()
			elseif lBold  == .F. .and. lItalic  == .T.
				cTag_Form := "<font color='"+ cColor + "'  face='"+ cFonte +"' size='"+ Alltrim(STR(nSize)) +"'px'<i>"+txt2html(cTag) +"</i></font>" + hb_eol()
			elseif lBold  == .T. .and. lItalic  == .T.
				cTag_Form := "<font color='"+ cColor + "'  face='"+ cFonte +"' size='"+ Alltrim(STR(nSize)) +"'px'<b><i>"+txt2html(cTag) +"</i></b></font>" + hb_eol()
			else	
				cFont_Form := txt2html(cTag) + hb_eol() 
			endif
 
 
			::cBody += ; // atributos de style tudo dentro das ' ' =  style= ' atributo1:valor1 ; atributo2:valor2 ' >
			"<table>"+;
				"<tr>"+;
					"<td align='" + cAlign_Col1 + "' width='"+alltrim(str(nWidth)) +"px'>"  + cTag_Form + "</td>" + hb_eol() + ;
					"<td align='" + cAlign_Col2 + "' width='700px'>" + cTexto + "</td>" +;
				"</tr>" +;
			"</table>"

			/**
			"<p align='" + cAlign + "' style= 'width:"+ alltrim(str(nWidth))+"px ; line-height:"+ alltrim(STR(nLineheight)) + "'>" + hb_eol() + ;
				cTag_Form  + "<br> align='left' 'width:"+ alltrim(str(700))+"px'" + cTexto + ">"  + ;
			"</p>"
			*/

	RETURN Self

	METHOD Generate() CLASS HB_THTML

		::cContent := ;
			"<html><head>" 												+ hb_eol() + ;
			"<title>" + ::cTitle + "</title>"                       	+ hb_eol() + ;
			"<body link='" + ::cLinkColor + "'" 								 	+;
			"vlink='" + ::cvLinkColor + "'>" 							+ hb_eol() + ;
		::cBody                                        					+ hb_eol() + ;
			"</body></html>"

	RETURN Self

	METHOD ShowResult() CLASS HB_THTML

		   OutStd( ;
				;//      "HTTP/1.0 200 OK"                + hb_eol() + ;
			"CONTENT-TYPE: TEXT/HTML"                     + hb_eol() + hb_eol() + ;
			  ::cContent )

	RETURN Self

	METHOD SaveToFile( cFile ) CLASS HB_THTML

		   LOCAL hFile := FCreate( cFile )

		   FWrite( hFile, ::cContent )
		   FClose( hFile )

	RETURN Self
	
	
function html2txt( cTexto )
	 
	   cTexto := strTran( cTexto,   "&aacute;"  ,  "á" )
	   cTexto := strTran( cTexto,   "&acirc;"   ,  "â" )
	   cTexto := strTran( cTexto,   "&agrave;"  ,  "à" )
	   cTexto := strTran( cTexto,   "&atilde;"  ,  "ã" )
	   cTexto := strTran( cTexto,   "&ccedil;"  ,  "ç" )
	   cTexto := strTran( cTexto,   "&eacute;"  ,  "é" )
	   cTexto := strTran( cTexto,   "&ecirc;"   ,  "ê" )
	   cTexto := strTran( cTexto,   "&iacute;"  ,  "í" )
	   cTexto := strTran( cTexto,   "&oacute;"  ,  "ó" )
	   cTexto := strTran( cTexto,   "&ocirc;"   ,  "ô" )
	   cTexto := strTran( cTexto,   "&otilde;"  ,  "õ" )
	   cTexto := strTran( cTexto,   "&uacute;"  ,  "ú" )
	   cTexto := strTran( cTexto,   "&uuml;"    ,  "ü" )
	   cTexto := strTran( cTexto,   "&Aacute;"  ,  "Á" )
	   cTexto := strTran( cTexto,   "&Acirc;"   ,  "Â" )
	   cTexto := strTran( cTexto,   "&Agrave;"  ,  "À" )
	   cTexto := strTran( cTexto,   "&Atilde;"  ,  "Ã" )
	   cTexto := strTran( cTexto,   "&Ccedil;"  ,  "Ç" )
	   cTexto := strTran( cTexto,   "&Eacute;"  ,  "É" )
	   cTexto := strTran( cTexto,   "&Ecirc;"   ,  "Ê" )
	   cTexto := strTran( cTexto,   "&Iacute;"  ,  "Í" )
	   cTexto := strTran( cTexto,   "&Oacute;"  ,  "Ó" )
	   cTexto := strTran( cTexto,   "&Ocirc;"   ,  "Ô" )
	   cTexto := strTran( cTexto,   "&Otilde;"  ,  "Õ" )
	   cTexto := strTran( cTexto,   "&Uacute;"  ,  "Ú" )
	   cTexto := strTran( cTexto,   "&Uuml;"    ,  "Ü" )
	 
	return ( cTexto )



function txt2html( cTexto )

	   cTexto := strTran( cTexto,  "á",   "&aacute;"   )
	   cTexto := strTran( cTexto,  "â",   "&acirc;"    )
	   cTexto := strTran( cTexto,  "à",   "&agrave;"   )
	   cTexto := strTran( cTexto,  "ã",   "&atilde;"   )
	   cTexto := strTran( cTexto,  "ç",   "&ccedil;"   )
	   cTexto := strTran( cTexto,  "é",   "&eacute;"   )
	   cTexto := strTran( cTexto,  "ê",   "&ecirc;"    )
	   cTexto := strTran( cTexto,  "í",   "&iacute;"   )
	   cTexto := strTran( cTexto,  "ó",   "&oacute;"   )
	   cTexto := strTran( cTexto,  "ô",   "&ocirc;"    )
	   cTexto := strTran( cTexto,  "õ",   "&otilde;"   )
	   cTexto := strTran( cTexto,  "ú",   "&uacute;"   )
	   cTexto := strTran( cTexto,  "ü",   "&uuml;"     )
	   cTexto := strTran( cTexto,  "Á",   "&Aacute;"   )
	   cTexto := strTran( cTexto,  "Â",   "&Acirc;"    )
	   cTexto := strTran( cTexto,  "À",   "&Agrave;"   )
	   cTexto := strTran( cTexto,  "Ã",   "&Atilde;"   )
	   cTexto := strTran( cTexto,  "Ç",   "&Ccedil;"   )
	   cTexto := strTran( cTexto,  "É",    "&Eacute;"   )
	   cTexto := strTran( cTexto,  "Ê",   "&Ecirc;"    )
	   cTexto := strTran( cTexto,  "Í",   "&Iacute;"   )
	   cTexto := strTran( cTexto,  "Ó",   "&Oacute;"   )
	   cTexto := strTran( cTexto,  "Ô",   "&Ocirc;"    )
	   cTexto := strTran( cTexto,  "Õ",   "&Otilde;"   )
	   cTexto := strTran( cTexto,  "Ú",   "&Uacute;"   )
	   cTexto := strTran( cTexto,  "Ü",   "&Uuml;"    )
	 
	return ( cTexto )

Code: Select all


		oHTML := HB_THTML_CSS():New()
		//oHTML:SetTitle( "Harbour Power Demonstration" )
		oHTML:AddHead( "SOLICITAÇÃO COMPRAS Num. : " 	+ aStruc[12] )
		oHTML:AddPara( "Prioridade : " 					+ aStruc[10],"right" , 200 , .T.,,,, 4 )
		oHTML:AddPara( "Status : " 						+ aStruc[11],"right" , 200 , .T.,,,, 4 )
		oHTML:AddPara( "Requisitante : " 				+ aStruc[1], "right" , 200 , .T.,,,, 4 )
		oHTML:AddPara( "Grupo/Setor : " 				+ aStruc[2], "right" , 200 , .T.,,,, 4 )
		oHTML:AddPara( "Data da Solitação : " 			+ aStruc[3], "right" , 200 , .T.,,,, 4 )
		oHTML:AddPara( "Data de Aprovação : " 			+ aStruc[4], "right" , 200 , .T.,,,, 4 )
		oHTML:AddPara( "Data de Previsão : " 			+ aStruc[5], "right" , 200 , .T.,,,, 4 )
		oHTML:AddPara( "Data de Entrega : " 			+ aStruc[6], "right" , 200 , .T.,,,, 4 )
		oHTML:AddPara( "Ordem de Compra : " 			+ aStruc[7], "right" , 200 , .T.,,,, 4 )
		oHTML:AddPara( "Maquina : "						+ aStruc[8], "right" , 200 , .T.,,,, 4 )
		oHTML:AddPara( "Observação : "					+ aStruc[9], "right" , 200 , .T.,,,, 4 )
		oHTML:AddPara( "por favor não responda este e-mail, ele serve apenas para comunicar a você e o solicitante de Manuteção.", "left" , 1000 , .T.,,,, 3.5 )
		oHTML:AddPara( "[MasterServ Manutenção]", "left" , 200 , .T. ,,,, 3.5)
		//oHTML:AddLink( "https://harbour.github.io", "Meet the Harbour power!" )
		oHTML:Generate(3) //Generate(nLineheight) line spacing
		//oHTML:ShowResult()
		oHTML:SaveToFile( "body.html" )	
		//cCorpoMsg2 := 	oHTML:ShowResult()