Recent

Author Topic: Indy email attachment  (Read 285 times)

lazarus9

  • Full Member
  • ***
  • Posts: 118
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]);

« Last Edit: May 22, 2019, 01:44:55 am by lazarus9 »

lucamar

  • Hero Member
  • *****
  • Posts: 2018
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 2.0.2/2.0.4  - FPC 3.0.4 on:
(K|L)Ubuntu 12..16, Windows XP SP3, various DOSes.

lazarus9

  • Full Member
  • ***
  • Posts: 118
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]);