Olá, no tópico anterior descobri como envia imagens em html no email, ele envia ok, porem..... envia junto um arquivo maluco... uma numeração .txt anexado ao email... e demora muito para enviar pois ele pega a imagem que está no PC.... teria como eu pegar a imagem do meu site!, eu até tenho ela já!
Segue o Código!
procedure TfrmEmailSuporte.Button1Click(Sender: TObject);
var
idAttach: TidAttachment;
idText1: TidText;
idText2: TidText;
p: TidMessageParts;
slBody: TStringList;
i : integer;
nomeimg : string;
caminhoimg : string;
sistema : string;
begin
IdMessage1.Clear;
IdMessage1.ClearBody;
IdMessage1.ClearHeader;
caminhoimg := 'C:\Propaganda Atualiza\';
if rbsigi.Checked = True then
begin
nomeimg := 'suporte_sigi.jpg';
sistema := 'Sigi';
end;
if rbsigicell.Checked = True then
begin
nomeimg := 'suporte_sigicell.jpg';
sistema := 'SigiCell';
end;
if rbsigiconv.Checked = True then
begin
nomeimg := 'suporte_sigiconv.jpg';
sistema := 'SigiConv';
end;
if rbsigigrupos.Checked = True then
begin
nomeimg := 'suporte_sigigrupos.jpg';
sistema := 'SigiGrupos';
end;
// idMessage1 has the email addresses and
// all the other info needed to send already set.
with IdMessage1 do
begin
Recipients.EMailAddresses:=edt_email.Text;
Subject:='Atualização sistema ' + sistema;
ContentType :='multipart/mixed';
ContentDisposition :='inline';
Encoding :=meMIME;
end;
p := idMessage1.MessageParts;
slBody := TstringList.Create;
try
slBody.Add('<html>');
slBody.Add('<head>');
slBody.Add('</head>');
slBody.Add('<body>');
slBody.Add('<img src="cid:'+ nomeimg +'" />');
//procedure
slBody.Add('</body>');
slBody.Add('</html>');
idText1 := TidText.Create(p, slBody);
idText1.ContentType := 'text/html';
idText2 := TidText.Create(p);
idText2.ContentType := 'text/plain';
idText2.Body.Text := '';
idAttach := TidAttachment.Create(p, caminhoimg + nomeimg);
idAttach.ContentType := 'image/jpeg';
idAttach.ContentDisposition := 'inline';
idAttach.ExtraHeaders.Values['content-id'] := nomeimg;
idMessage1.Body.Assign(slBody);
idAttach.DisplayName := nomeimg;
idMessage1.ContentType := 'multipart/mixed';
idSMTP1.Connect;
idSMTP1.Send(idMessage1);
finally
idSMTP1.Disconnect;
slBody.Free;
Showmessage('Enviado');
end;
end;
Pergunta
Douglas Soares
Olá, no tópico anterior descobri como envia imagens em html no email, ele envia ok, porem..... envia junto um arquivo maluco... uma numeração .txt anexado ao email... e demora muito para enviar pois ele pega a imagem que está no PC.... teria como eu pegar a imagem do meu site!, eu até tenho ela já!
Segue o Código!
procedure TfrmEmailSuporte.Button1Click(Sender: TObject); var idAttach: TidAttachment; idText1: TidText; idText2: TidText; p: TidMessageParts; slBody: TStringList; i : integer; nomeimg : string; caminhoimg : string; sistema : string; begin IdMessage1.Clear; IdMessage1.ClearBody; IdMessage1.ClearHeader; caminhoimg := 'C:\Propaganda Atualiza\'; if rbsigi.Checked = True then begin nomeimg := 'suporte_sigi.jpg'; sistema := 'Sigi'; end; if rbsigicell.Checked = True then begin nomeimg := 'suporte_sigicell.jpg'; sistema := 'SigiCell'; end; if rbsigiconv.Checked = True then begin nomeimg := 'suporte_sigiconv.jpg'; sistema := 'SigiConv'; end; if rbsigigrupos.Checked = True then begin nomeimg := 'suporte_sigigrupos.jpg'; sistema := 'SigiGrupos'; end; // idMessage1 has the email addresses and // all the other info needed to send already set. with IdMessage1 do begin Recipients.EMailAddresses:=edt_email.Text; Subject:='Atualização sistema ' + sistema; ContentType :='multipart/mixed'; ContentDisposition :='inline'; Encoding :=meMIME; end; p := idMessage1.MessageParts; slBody := TstringList.Create; try slBody.Add('<html>'); slBody.Add('<head>'); slBody.Add('</head>'); slBody.Add('<body>'); slBody.Add('<img src="cid:'+ nomeimg +'" />'); //procedure slBody.Add('</body>'); slBody.Add('</html>'); idText1 := TidText.Create(p, slBody); idText1.ContentType := 'text/html'; idText2 := TidText.Create(p); idText2.ContentType := 'text/plain'; idText2.Body.Text := ''; idAttach := TidAttachment.Create(p, caminhoimg + nomeimg); idAttach.ContentType := 'image/jpeg'; idAttach.ContentDisposition := 'inline'; idAttach.ExtraHeaders.Values['content-id'] := nomeimg; idMessage1.Body.Assign(slBody); idAttach.DisplayName := nomeimg; idMessage1.ContentType := 'multipart/mixed'; idSMTP1.Connect; idSMTP1.Send(idMessage1); finally idSMTP1.Disconnect; slBody.Free; Showmessage('Enviado'); end; end;Editado por Douglas_SoaresLink para o comentário
Compartilhar em outros sites
2 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.