Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1316
  • Last Modified:

turbo delphi 2006 and indy 10 error at compile time

I am migrating from Delphi 7 with indy 9 to Turbo Delphi 2006 with Indy 10
I get now errors that I didn't have with Delphi 7
I had code like this to attach 3 files to the an email message I prepared
 
M := TIDMessage.Create(Application);
 with M do
  begin
     .../...
     TIDAttachment.Create(MessageParts,File1);
     TIDAttachment.Create(MessageParts,File2);
      .../...
  end  ;

Now I get errors on the TIDAttachment.Create (it is the french version, I translate) :

[Pascal Warning] U0116a.pas(282): W1020 Instance constructor of 'TIdAttachment' containing abstract method 'TIdAttachment.OpenLoadStream'
[Pascal Erreur] U0116a.pas(283): E2034 Too many parameters

Surely something has changed in Indy, but how should I code this now ???
0
LeTay
Asked:
LeTay
  • 2
1 Solution
 
TNameCommented:
I think you either have to do this:
 MyIDAttachment:=TIDAttachment.Create(MessageParts);
 MyIDAttachment.FileName:='SomeFile.txt';

or
uses IDAttachmentFile;
...
MyIDAttachmentFile:=TIDAttachmentFile.Create(MessageParts, AFileName);

http://support.borland.com/entry.jspa?categoryID=148&externalID=4651

 
0
 
Wim ten BrinkCommented:
Several things have changed in Indy and as a result, it's not backwards-compatible with previous versions. And yes, that sucks! So if you have more code that relies on Indy then first get familiar with the new Indy components.
0
 
LeTayAuthor Commented:
Hello TName,
I will try what you suggest
But how can I put several (unknow number at compile time) attachments then ?
0
 
TNameCommented:
Haven't tried it, but basically you should replace TIDAttachment with TIDAttachmentFile. There are some differences though, have a look at this:

http://72.14.221.104/search?q=cache:WDiMSiMTTsMJ:www.indyproject.org/Sockets/Blogs/RLebeau/2005_08_17_A.iwp

Example from the link above:

    with TIdAttachmentFile.Create(IdMessage1.MessageParts, 'c:\folder\image1.jpg') do begin
      ContentID := '12345';
      ContentType := 'image/jpeg';
      FileName := 'image1.jpg';
    end;

    with TIdAttachmentFile.Create(IdMessage1.MessageParts, 'c:\folder\image2.jpg') do begin
      ContentID := '56789';
      ContentType := 'image/jpeg';
      FileName := 'image2.jpg';
    end;

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now