Recent

Author Topic: Indy email attachment  (Read 1457 times)

guest48704

  • Guest
Indy email attachment
« on: May 22, 2019, 01:08:28 am »
I found this example, but it no longer works.  It says that there are too many parameters in TIdAttachment.Create.  This must be an old example from I9.  Does anyone have a good Indy 10 attachment example?  Thanks

Code: [Select]
uses IdAttachment

Attachment: TIdAttachment;

for x := 0 to ListBox1.Items.Count-1 do
    Attachment := TIdAttachment.Create(IdMessage1.MessageParts, ListBox1.Items.Strings[x]);


lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Indy email attachment
« Reply #1 on: May 22, 2019, 01:27:59 am »
Please, use [code] tags to insert code snippets into your posts. Otherwise they get mangled very easily, as you can see in your post.

Code: Pascal  [Select][+][-]
  1. uses IdAttachment
  2.  
  3. Attachment: TIdAttachment;
  4.  
  5. for x := 0 to ListBox1.Items.Count-1 do
  6.     Attachment := TIdAttachment.Create(IdMessage1.MessageParts, ListBox1.Items.Strings[x]);
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

guest48704

  • Guest
Re: Indy email attachment
« Reply #2 on: May 22, 2019, 01:47:39 am »
Found the solution:

Code: [Select]
use IdAttachmentFile

Attachment: IdAttachmentFile

for x := 0 to ListBox1.Items.Count-1 do
    Attachment := TIdAttachmentFile.Create(IdMessage1.MessageParts, ListBox1.Items.Strings[x]);

 

TinyPortal © 2005-2018