sendmail Attach property
Return to Introduction  Previous page  Next page
Applies to
SendMail component.  

Declaration
property Attach: TStringList;  

Description
The Attach property specifies the file names which should be included to the e-mail message on dispatching.  
 
The Attach property is the list of strings (TStringList), where every line is the file name including full path to the file.  
 
tip The files can be attached as "external" or as "internal" (embedded) data. For example, you might want to embed additional pictures to the body of HTML message. See AttachType property for more details.  
 
iiwarning If attached file could not be found (moved, renamed or deleted before sending), the OnCantAttach event occurs. However, this is not fatal error and SendMail usually continue sending the e-mail, skipping the lost file.  

Example
procedure TForm1.AttachBtnClick(Sender: TObject);  
var  
  I: Integer;  
begin  
  with OpenDialog1 do // TOpenDialog on form  
   if Execute and (I <> Files.Count) then  
     for I := 0 to Files.Count - 1 do  
       SendMail1.Attach.Add(Files[I]);  
end;  

See also
AttachType property;  
OnCantAttach event.