Amiguinho,
Use esta minha idéia:
Cabeçalho, arquivo PEDIDOC.TPL:
Código: Selecionar todos
<HTML>
<head>
<style>
.form-title {
background-color: #ffffff;
color: #141414;
font-weight: bold;
}
.form-field-caption {
font-style:italic;
}
.table-row {
background-color: #f1f3f7;
}
.table-head {
background-color: #bbbbbb;
}
</style>
</head>
<body>
<style type="text/css">
body,th,td,tt,p,div,span {
color: #000000;
font-family: tahoma, verdana, arial, sans-serif;
font-size: 11px;
}
p,ul {
margin-top: 6px;
margin-bottom: 6px;
}
.form-field-caption {
font-style:italic;
}
.form-title {
background-color: #ffffff;
color: #141414;
font-weight: bold;
}
</style>
<table cellpadding="0" cellspacing="0" width="100%" border="0">
<tr>
<td>
<img src="logo.gif" width="1" height="1" border="0" alt="" />
</td>
<td width="600" style="border: #444444; border-style: solid; border-width: 2px" align="center">
<table cellpadding="10" cellspacing="0" width="100%" border="0">
<tr>
<td>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td valign="top"><p></p>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td valign="top">
<img src="logo.gif" border="0" alt="5V-Cart.com" />
</td>
<td> </td>
<td valign="top" style="font-family: Verdana,Tahoma; font-size:10px">
<div style="font-family: Arial; font-size:14px"><b>{#empresa#}</b></div>
{#endereco#}<br />
{#cidade#}<br />
{#pais#}<br />
<b>Telefone</b>: {#telefone#}<br />
<b>Telefone 2</b>: {#fax#}<br />
<b>Web site</b>: {#website#}<br />
<b>E-mail</b>: <u>{#email#}</u><br />
</td>
</tr>
</table>
</td>
<td valign="top" align="right">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td valign="top" style="font-family: Tahoma,Arial, Verdana,Tahoma; font-size:11px">
<div align="center" style="font-size:22px; font-family: Tahoma,Arial; text-transform: uppercase;" nowrap="nowrap"><b>PEDIDO</b></div>
<b>Pedido:</b> {#idpedido#}<br />
<b>Status:</b> {#situacao#}<br />
<b>Data:</b> {#dataped#}<br />
<b>Método de pagamento:</b> {#idcondicao#}<br />
<b>Método de remessa:</b> {#identrega#}<br />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<!-- td valign="right" style="font-family: Code39; font-size:14px"><b>{#idpedido#}</b></td -->
<!-- td align="right" colspan="2"><img src='"file://C:\Meus Arquivos\eudora\Embedded\csimg21.png"' alt="BarCode" width="250" height="60" / -->
</tr>
</table>
<p></p>
<br />
<table cellpadding="4" cellspacing="0" border="0" width="100%">
<tr>
<td valign="top" width="50%">
<table cellpadding="1" cellspacing="1" border="0" width="100%">
<tr>
<td colspan="2" class="form-title">Informação de contato<hr size="1" noshade="noshade" /></td>
</tr>
<tr>
<td class="form-field-caption" width="30%" nowrap="nowrap">Nome: </td>
<td>{#ClienteNome#}</td>
</tr>
<tr>
<td class="form-field-caption" width="30%" nowrap="nowrap">E-mail: </td>
<td>{#ClienteEmail#}</td>
</tr>
</table>
</td>
<td width="1%"> </td>
<td valign="top" width="49%">
<table cellpadding="1" cellspacing="1" border="0" width="100%">
<tr>
<td colspan="2" class="form-title"> <hr size="1" noshade="noshade" /></td>
</tr>
<tr>
<td class="form-field-caption" width="30%" nowrap="nowrap">Telefone: </td>
<td>{#ClienteTelefone#}</td>
</tr>
<tr>
<td class="form-field-caption" width="30%" nowrap="nowrap">Fax: </td>
<td>{#ClienteFax#}</td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top">
<p></p>
<table cellpadding="1" cellspacing="1" border="0" width="100%">
<tr>
<td colspan="2" class="form-title">Endereço de pagamento<hr size="1" noshade="noshade" /></td>
</tr>
<tr>
<td class="form-field-caption" width="30%" nowrap="nowrap">Endereço: </td>
<td>{#ClientePEndereco#}</td>
</tr>
<tr>
<td class="form-field-caption" width="30%" nowrap="nowrap">Cidade: </td>
<td>{#ClientePCidade#}</td>
</tr>
<tr>
<td class="form-field-caption" width="30%" nowrap="nowrap">Estado: </td>
<td>{#ClientePEstado#}</td>
</tr>
<tr>
<td class="form-field-caption" width="30%" nowrap="nowrap">CEP: </td>
<td>{#ClientePCep#}</td>
</tr>
</table>
</td>
<td> </td>
<td valign="top">
<p></p>
<table cellpadding="1" cellspacing="1" border="0" width="100%">
<tr>
<td colspan="2" class="form-title">Endereço de remessa<hr size="1" noshade="noshade" /></td>
</tr>
<tr>
<td class="form-field-caption" width="30%" nowrap="nowrap">Endereço: </td>
<td>{#ClienteREndereco#}</td>
</tr>
<tr>
<td class="form-field-caption" width="30%" nowrap="nowrap">Cidade: </td>
<td>{#ClienteRCidade#}</td>
</tr>
<tr>
<td class="form-field-caption" width="30%" nowrap="nowrap">Estado: </td>
<td>{#ClienteREstado#}</td>
</tr>
<tr>
<td class="form-field-caption" width="30%" nowrap="nowrap">CEP: </td>
<td>{#ClienteRCep#}</td>
</tr>
</table>
</td>
</tr>
</table>
<p></p><br />
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td valign="top">
<table cellpadding="2" cellspacing="1" border="0" width="100%" bgcolor="#000000">
<tr>
<td width="10%" align="center" bgcolor="#dddddd"><b>CODIGO</b></td>
<td width="50%" bgcolor="#dddddd"><b>Produto</b></td>
<td width="10%" bgcolor="#dddddd" nowrap="nowrap"><b>Medida</b></td>
<td width="10%" align="center" bgcolor="#dddddd"><b>Quantidade</b></td>
<td width="10%" align="center" bgcolor="#dddddd" nowrap="nowrap"><b>Unitario</b></td>
<td width="10%" align="center" bgcolor="#dddddd"><b>Desconto</b></td>
<td width="10%" align="center" bgcolor="#dddddd"><b>Subtotal</b></td>
</tr>
Produtos, arquivo PEDIDOI.TPL:
Código: Selecionar todos
<tr>
<td bgcolor="#ffffff">{#Codigo#}</td>
<td bgcolor="#ffffff">{#Descricao#}</td>
<td bgcolor="#ffffff"> {#Medida#}</td>
<td bgcolor="#ffffff" align="center">{#Quantidade#}</td>
<td bgcolor="#ffffff" align="right">R$ {#Unitario#}</td>
<td bgcolor="#ffffff" align="right">R$ {#Desconto#}</td>
<td align="right" bgcolor="#ffffff"><b>R$ {#SubTotal#}</b> </td>
</tr>
Rodape, arquivo PEDIDOR.TPL:
Código: Selecionar todos
</table>
</td>
</tr>
</table>
<div align="right">
<table>
<tr>
<td align="right" nowrap="nowrap"><b>Subtotal:</b> </td>
<td align="right" nowrap="nowrap">R$ {#tt_SubTotal#}</td>
</tr>
<tr>
<td nowrap="nowrap" align="right"><b>Desconto incluso:</b> </td>
<td nowrap="nowrap" align="right">
R$ {#tt_Desconto#}</td>
</tr>
<!-- tr>
<td align="right" nowrap="nowrap"><b>Custo de remessa:</b> </td>
<td align="right" nowrap="nowrap">R$ {#tt_Frete#}</td>
</tr -->
<tr>
<td colspan="2"><div style="border: solid #444444 0px;border-bottom-width: 2px;padding-top:2px"><img src="file://C:\Meus Arquivos\eudora\Embedded\csimg01.gif" width="1" height="1" border="0" alt="" /></div></td>
</tr>
<tr>
<td align="right" nowrap="nowrap"><b>Custo Total:</b> </td>
<td align="right" nowrap="nowrap">R$ {#tt_Total#}</td>
</tr>
</table><br />
</div>
</td>
</tr>
</table>
</td>
<td>
<img src="file://C:\Meus Arquivos\eudora\Embedded\csimg01.gif" width="1" height="1" border="0" alt="" /></td>
</tr>
</table>
</body>
</html>
Altere as variáveis contidas entre {# e #} com váriaveis de suas tabelas envolvidas.
Trecho de meu sistema de envio de pedidos por email. Veja, analise e adapte aos seus dados e campos:
Código: Selecionar todos
cHTMLFile := STRZERO(RANDOM(99999999))+".HTM"
do case
case _oque_ = "P" // Pedido
cHTMLName := "PEDIDO DE VENDA"
cHTMLFile := "PE"+STRZERO(M->IDPEDIDO,6)+".HTM"
case _oque_ = "O" // Orcamento
cHTMLName := "ORCAMENTO"
cHTMLFile := "OC"+STRZERO(M->IDPEDIDO,6)+".HTM"
case _oque_ = "I" // Informe de Comissao
cHTMLName := "INFORME DE COMISSAO"
cHTMLFile := "IC"+STRZERO(M->IDPEDIDO,6)+".HTM"
endcase
// Faço a leitura do cabecalho e o seu preenchimento por StrTran()
cTPLFile := "PEDIDOC.TPL"
if !file( cTPLFile )
? "Template de cabecalho "+cTPLFile+" nao encontrado."
dbSelectArea( "PN" )
OrdSetFocus( 1 )
return .t.
endif
cHTMLFile1 := MemoRead( cTPLFile )
// Dados da empresa que esta enviando o pedido
cHTMLFile1 := StrTran( cHTMLFile1, "{#empresa#}" , Cl_Nome )
cHTMLFile1 := StrTran( cHTMLFile1, "{#endereco#}" , Cl_Endereco )
cHTMLFile1 := StrTran( cHTMLFile1, "{#cidade#}" , Cl_Cidade )
cHTMLFile1 := StrTran( cHTMLFile1, "{#pais#}" , "Brasil" )
cHTMLFile1 := StrTran( cHTMLFile1, "{#telefone#}" , Cl_Telefone )
cHTMLFile1 := StrTran( cHTMLFile1, "{#fax#}" , Cl_Fax )
cHTMLFile1 := StrTran( cHTMLFile1, "{#website#}" , "www.website.com" )
cHTMLFile1 := StrTran( cHTMLFile1, "{#email#}" , Cl_Email )
// Dados do pedido
cHTMLFile1 := StrTran( cHTMLFile1, "{#idpedido#}" , str( M->IDPEDIDO, 6 ) )
cHTMLFile1 := StrTran( cHTMLFile1, "{#situacao#}" , M->PRN_AVALIACAO )
cHTMLFile1 := StrTran( cHTMLFile1, "{#dataped#}" , dtoc( M->PRN_DATAPED ) )
cHTMLFile1 := StrTran( cHTMLFile1, "{#idcondicao#}" , M->PRN_IDCONDICAO )
cHTMLFile1 := StrTran( cHTMLFile1, "{#identrega#}" , M->PRN_TR_NOME )
cHTMLFile1 := StrTran( cHTMLFile1, "{#barcode#}" , "BARCODE" )
// Dados do cliente destinatario
cHTMLFile1 := StrTran( cHTMLFile1, "{#ClienteNome#}" , M->PRN_NOME )
cHTMLFile1 := StrTran( cHTMLFile1, "{#ClienteEmail#}" , M->PRN_EMAIL )
cHTMLFile1 := StrTran( cHTMLFile1, "{#ClienteTelefone#}" , M->PRN_TELEFONE )
cHTMLFile1 := StrTran( cHTMLFile1, "{#ClienteFax#}" , M->PRN_FAX )
cHTMLFile1 := StrTran( cHTMLFile1, "{#ClientePEndereco#}", M->PRN_LOCCOBR )
cHTMLFile1 := StrTran( cHTMLFile1, "{#ClientePCidade#}" , M->PRN_CIDCOBR )
cHTMLFile1 := StrTran( cHTMLFile1, "{#ClientePEstado#}" , M->PRN_ESTCOBR )
cHTMLFile1 := StrTran( cHTMLFile1, "{#ClientePCep#}" , M->PRN_CEPCOBR )
cHTMLFile1 := StrTran( cHTMLFile1, "{#ClienteREndereco#}", M->PRN_ENDERECO )
cHTMLFile1 := StrTran( cHTMLFile1, "{#ClienteRCidade#}" , M->PRN_CIDADE )
cHTMLFile1 := StrTran( cHTMLFile1, "{#ClienteREstado#}" , M->PRN_ESTADO )
cHTMLFile1 := StrTran( cHTMLFile1, "{#ClienteRCep#}" , M->PRN_CEP )
// Seleciono os itens relativos ao pedido em questao
dbSelectArea( "ITENS" )
OrdSetFocus( 3 )
dbSeek(str(_num_,6,0))
OrdScope(0,STR(_num_,6,0))
OrdScope(1,STR(_num_,6,0))
dbGoTop()
M->SUBTOTAL := 0
M->DESCONTO := 0
// Faço a leitura da parte de itens e o seu preenchimento por StrTran()
cTPLFile := "PEDIDOI.TPL"
if !file( cTPLFile )
MsgStop( "Template de itens "+cTPLFile+" nao encontrado." )
dbSelectArea( "PN" )
OrdSetFocus( 1 )
return .t.
endif
cHTMLFile2 := MemoRead( cTPLFile )
cHTMLFile22 := ""
DO WHILE .NOT. EOF()
cHTMLFile21 := ""
cHTMLFile21 := StrTran( cHTMLFile2 , "{#Resumido#}" , SUBSTR(ES->RESUMIDO,1,10) )
cHTMLFile21 := StrTran( cHTMLFile21, "{#Descricao#}" , ALLTRIM(SUBSTR(ES->DESCRICAO,1,45)) )
cHTMLFile21 := StrTran( cHTMLFile21, "{#Medida#}" , ES->MEDIDA )
cHTMLFile21 := StrTran( cHTMLFile21, "{#Quantidade#}", TRANSF(ES->QUANTIDADE,ES->MASCARA) )
cHTMLFile21 := StrTran( cHTMLFile21, "{#Unitario#}" , TRANSF(ES->VALORVENDA,"@E 99,999.99") )
cHTMLFile21 := StrTran( cHTMLFile21, "{#Desconto#}" , TRANSF(ES->DESCONTO,"@E 99,999.99") )
cHTMLFile21 := StrTran( cHTMLFile21, "{#SubTotal#}" , TRANSF(ES->SUBTOTAL,"@E 99,999.99") )
cHTMLFile22 := cHTMLFile22 + cHTMLFile21
M->SUBTOTAL := M->SUBTOTAL + ES->SUBTOTAL
M->DESCONTO := M->DESCONTO + ES->DESCONTO
SKIP
ENDDO
// Faço a leitura do rodape e o seu preenchimento por StrTran()
cTPLFile := "PEDIDOR.TPL"
if !file( cTPLFile )
MsgStop( "Template de rodape "+cTPLFile+" nao encontrado." )
dbSelectArea( "PEDIDOS" )
OrdSetFocus( 1 )
return .t.
endif
cHTMLFile3 := MemoRead( cTPLFile )
cHTMLFile31 := StrTran( cHTMLFile3 , "{#tt_SubTotal#}", TRANSF(M->SUBTOTAL,"@E 99,999.99") )
cHTMLFile31 := StrTran( cHTMLFile31, "{#tt_Desconto#}", TRANSF(M->DESCONTO,"@E 99,999.99") )
cHTMLFile31 := StrTran( cHTMLFile31, "{#tt_Frete#}" , TRANSF(M->FRETE,"@E 99,999.99") )
cHTMLFile31 := StrTran( cHTMLFile31, "{#tt_Total#}" , TRANSF((M->SUBTOTAL-M->DESCONTO),"@E 99,999.99") )
// Faço a escritura do arquivo HTML completado e pornto para o envio
MemoWrit( cHTMLFile, cHTMLFile1 + cHTMLFile22 + cHTMLFile31 )
Após a criação do arquivo devo efetuar o envio do email lembrando que tenho de passar para o aplicativo que enviará que o BODY estará em HTML e ainda assim envio o arquivo como anexo.