Estou a semana toda me matando por uma coisa meio que boba... por isso estou meio inativo essa semana.... estão me cobrando... preciso entregar até amanha e peço ajuda aos que puderem me ajudar :rolleyes:
Seguinte...
Eu envio perfeitamente o email para qualquer caixa postal do mundo (todas que testei chegou normal)... porém o GMAIL só recebe o anexo e o assunto... o texto não vai...
Eu uso um richedit e converto ele para HTML pra enviar o email...
Segue procedure PROCESSO, a responsável pelo envio do email...
function TfrmCobrancaSenhas.RICH_HTML(RICH: TRichEdit): string;
var
I,J,MAX_ARRAY: integer;
HTML: string;
F,FO: array [0..5] of string;
STR,LGT: integer;
SIZE: integer;
COR : string;
begin
HTML := '';
STR := RICH.SelStart;
LGT := RICH.SelLength;
MAX_ARRAY := 5;
for J := 0 to MAX_ARRAY do
begin
F[J] := '';
FO[J] := '';
end;
for I := 0 to length(RICH.text) do
begin
RICH.SelStart := I;
RICH.SelLength := 1;
for J := 0 to MAX_ARRAY do
FO[J] := F[J];
if (RICH.SelAttributes.Style - [fsItalic] - [fsUnderline] - [fsStrikeOut] = [fsBold]) then
F[0] := '<b>'
else
F[0] := '</b>';
if (RICH.SelAttributes.Style - [fsItalic] - [fsBold] - [fsStrikeOut] = [fsUnderline]) then
F[1] := '<u>'
else
F[1] := '</u>';
if (RICH.SelAttributes.Style - [fsUnderline] - [fsBold] - [fsStrikeOut] = [fsItalic]) then
F[2] := '<i>'
else
F[2] := '</i>';
if RICH.SelAttributes.size < 10 then
SIZE := 1
else if RICH.SelAttributes.size < 12 then
SIZE := 2
else if RICH.SelAttributes.size < 14 then
SIZE := 3
else if RICH.SelAttributes.size < 18 then
SIZE := 4
else if RICH.SelAttributes.size < 22 then
SIZE := 5
else if RICH.SelAttributes.size < 32 then
SIZE := 6
else
SIZE := 7;
COR := ColorToString(RICH.SelAttributes.Color);
if (COR = 'clWindowText') or (COR = 'clBlack') then
COR := '#000000'
else if COR = 'clWite' then
COR := '#FFFFFF'
else if COR = 'clAqua' then
COR := '#00FFFF'
else if COR = 'clFuchsia' then
COR := '#FF00FF'
else if COR = 'clBlue' then
COR := '#0000FF'
else if COR = 'clYellow' then
COR := '#FFFF00'
else if COR = 'clLime' then
COR := '#00FF00'
else if COR = 'clRed' then
COR := '#FF0000'
else if COR = 'clSilver' then
COR := '#C0C0C0'
else if COR = 'clGray' then
COR := '#808080'
else if COR = 'clTeal' then
COR := '#008080'
else if COR = 'clPurple' then
COR := '#800080'
else if COR = 'clNavy' then
COR := '#000080'
else if COR = 'clOlive' then
COR := '#808000'
else if COR = 'clGreen' then
COR := '#008000'
else if COR = 'clMaroon' then
COR := '#800000'
else if copy(COR,1,1) = '$' then
COR := '#'+copy(COR,length(COR)-1,2)
+copy(COR,length(COR)-3,2)
+copy(COR,length(COR)-5,2)
else
COR := '#000000';
F[3] := '</font><font face="'+RICH.SelAttributes.Name+'" size='+inttostr(SIZE)+' color="'+COR+'">';
if RICH.Paragraph.Alignment = taCenter then
F[4] := '<center>'
else
F[4] := '</center>';
if RICH.Paragraph.Alignment = taRightJustify then
F[5] := '<div align="right">'
else
F[5] := '</div>';
for J := 0 to MAX_ARRAY do
if FO[J] <> F[J] then
HTML := HTML + F[J];
if copy(RICH.text,I+1,1) = #13 then
HTML := HTML + '<br>';
HTML := HTML + copy(RICH.text,I+1,1);
end;
RICH.SelStart := STR;
RICH.SelLength := LGT;
HTML := StringReplace(HTML,'[img]','<img src="',[rfReplaceAll]);
HTML := StringReplace(HTML,'[/img]','"/>',[rfReplaceAll]);
result := HTML;
end;
Explicando... o RichEdit 1 é onde a pessoa edita o texto que já vem e formata ele a vontade... já o RichEdit2 é o texto porém convertido em HTML pela função acima.
Como você pode perceber, tenho o HTML la na procedure PROCESSO, e quando chego no <body> eu coloco o texto do richedit2...
Não sei mais o que fazer... será que alguém pode dar uma luz???
Pergunta
Douglas Soares
Boa tarde...
Estou a semana toda me matando por uma coisa meio que boba... por isso estou meio inativo essa semana.... estão me cobrando... preciso entregar até amanha e peço ajuda aos que puderem me ajudar :rolleyes:
Seguinte...
Eu envio perfeitamente o email para qualquer caixa postal do mundo (todas que testei chegou normal)... porém o GMAIL só recebe o anexo e o assunto... o texto não vai...
Eu uso um richedit e converto ele para HTML pra enviar o email...
Segue procedure PROCESSO, a responsável pelo envio do email...
procedure ThreadCobranca.Processo; var idText1: TidText; idText2: TidText; p: TidMessageParts; slBody: TStringList; nomeimg : string; sistema : string; i : integer; tamanho_msg : TMemoryStream; begin try frmCobrancaSenhas.IdMessage1.Clear; frmCobrancaSenhas.IdMessage1.ClearBody; frmCobrancaSenhas.IdMessage1.ClearHeader; with frmCobrancaSenhas.IdMessage1 do begin From.Name := 'SN Systems'; From.Address := frmCobrancaSenhas.combo_de.Text; Recipients.EMailAddresses := frmCobrancaSenhas.edt_para.Text; CCList.EMailAddresses := frmCobrancaSenhas.edt_paracc.Text; BccList.EMailAddresses := frmCobrancaSenhas.edt_paracco.Text; Subject := frmCobrancaSenhas.edt_assunto.Text; ContentType :='multipart/mixed'; ContentDisposition :='inline'; Encoding :=meMIME; end; p := frmCobrancaSenhas.idMessage1.MessageParts; slBody := TstringList.Create; try slBody.Clear; slBody.Add('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' + '<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head>' + '<body bgcolor="#ffffff">' + frmCobrancaSenhas.RichEdit2.Text + '<br><br><font size="3">Atenciosamente,</font><br /><br /><table border="0" cellpadding="0" cellspacing="0" width="280">' + '<td valign="top"><img name="logosn" src="http://www.soareseneves.com.br/imagens/logosn.gif" width="95" height="50" border="0" id="logosn" alt="" /></td> <td valign="top"><font size="3">' + usuarioCompleto + '<br />' + LowerCase(usuario) + '@soareseneves.com.br</font><br /><font size="3">www.soareseneves.com.br<br /> (19) 3862-6674</font></td></tr><tr><td colspan="2">' + '<img name="rodapeoutlook" src="http://www.soareseneves.com.br/imagens/rodapeoutlook.gif" width="280" height="21" border="0" id="rodapeoutlook" alt="" />' + '</td></tr></table></body></html>'); idText1 := TidText.Create(p, slBody); idText1.ContentType := 'text/html'; idText2 := TidText.Create(p); idText2.ContentType := 'text/plain'; idText2.Body.Text := ''; frmCobrancaSenhas.idMessage1.Body.Assign(slBody); frmCobrancaSenhas.idMessage1.ContentType := 'multipart/mixed'; for i := 0 to frmCobrancaSenhas.FileListBox1.Items.Count - 1 do begin if FileExists(frmCobrancaSenhas.FileListBox1.Items[i]) then TIdAttachment.Create(frmCobrancaSenhas.IdMessage1.MessageParts, frmCobrancaSenhas.FileListBox1.Items[i]); end; tamanho_msg := TMemoryStream.create; frmCobrancaSenhas.IdMessage1.SaveToStream(tamanho_msg); Tamanho := tamanho_msg.Size; ShowMessage(frmCobrancaSenhas.IdMessage1.Body.Text); frmCobrancaSenhas.idSMTP1.Connect; frmCobrancaSenhas.idSMTP1.Send(frmCobrancaSenhas.idMessage1); finally frmCobrancaSenhas.idSMTP1.Disconnect; slBody.Free; end; frmCobrancaSenhas.Button1.Enabled := True; Synchronize(Mensagem1); except On E:Exception do begin ShowMessage('Erro: ' + E.Message); end; end; end;Função que converte para HTML: Converto e em seguida executo a ThreadExplicando... o RichEdit 1 é onde a pessoa edita o texto que já vem e formata ele a vontade... já o RichEdit2 é o texto porém convertido em HTML pela função acima.
Como você pode perceber, tenho o HTML la na procedure PROCESSO, e quando chego no <body> eu coloco o texto do richedit2...
Não sei mais o que fazer... será que alguém pode dar uma luz???
Abraços
Link para o comentário
Compartilhar em outros sites
5 respostass a esta questão
Posts Recomendados
Participe da discussão
Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.