Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > VCL

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 07-23-2012, 02:14 PM
mbdelphi mbdelphi is offline
Junior Member
 
Join Date: Mar 2005
Posts: 12
Default WHERE IS THE ERROR making an attachement

I got an erros on the attachmente line....

Any ideas?

dELPHI xe2

Code:
procedure TForm1.Button1Click(Sender: TObject);
var
  Email: TIdMessage;
  Texto: TIdText;
  Html: TIdText;
  Anexo: TIdAttachment;
begin
  Email := TIdMessage.Create(nil);
  try
    // ...ajusta remetente, destinatário, etc...

    // define o tipo do conteúdo da mensagem
    Email.ContentType := 'multipart/mixed';

    // cria a parte texto - pode estar em branco
    Texto := TIdText.Create(Email.MessageParts);
    Texto.Body.Text :=
      'This message contains HTML and images.';
    Texto.ContentType := 'text/plain';

    // cria a parte HTML
    Html := TIdText.Create(Email.MessageParts);
    Html.Body.Text := '<html><body>'
      + 'Mensagem de <b>Teste</b><br />'
      + '<img src="cid:imagem.jpg" />'
      + '</body></html>';
    Html.ContentType := 'text/html';

    // inclui no email a imagem usada na parte HTML
    Anexo := TIdAttachment.Create(Email.MessageParts, 'c:\pasta\imagem.jpg');     <<<<<<<<<<<<<<<<<<< THIS LINE HAS ERROR
    //email.MessageParts.Add('c:\pasta\imagem.jpg'));
    Anexo.ContentType := 'image/jpg';
    Anexo.Headers.Add('Content-ID: <imagem.jpg>');

    // ... envia o email...
  finally
    Email.Free;
  end;
end;
Reply With Quote
  #2  
Old 07-23-2012, 02:51 PM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 6,699
Default

My spanish is bad (read: I really have no clue what is says...), so I'm not able to understand your comments

But I'm missing the error you get? An error is far to general to guide you in the right direction
Reply With Quote
  #3  
Old 08-16-2012, 07:12 PM
emailx45 emailx45 is offline
Junior Member
 
Join Date: May 2012
Posts: 18
Default Sending Email Messages with Attachments using Delphi and Indy

http://delphi.about.com/od/indy/a/email-send-indy.htm
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:14 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.