Question

How to send attachment using TIdyAttachment ?

How to convert this TIdAttachment.Create(msg.MessageParts, 'c:\attach.bmp'); delphi statement to c++ builder ? How to use this abstract class in c++ builder? Due to it's being abstract I cannot create an instance of it !!!

Was it helpful?

Solution

Note that TIdAttachment is indeed abstract (as Remy Lebeau noted in a comment). Use TIdAttachmentFile instead. In C++, I guess it should look like (Update: I see you already found that):

TIdAttachmentFile *attachment = new TIdAttachmentFile(msg->MessageParts, "C:\\attach.bmp");

FWIW, named constructor calls like TMyClass.Create(args) in Delphi are translated as new TMyClass(args) in C++Builder. That is why Delphi often overloads Create, instead of using differently named constructors like CreateWithSpecialParams. In Delphi, a constructor can have any name, but not in C++.

Note that in Delphi you can have a constructor Create(Integer) and a constructor CreateEx(Integer) and they are distinguishable. This is not translatable to C++Builder, since both translate to MyClass(int), so doing that should be avoided if the Delphi programmer wants his or her class to be usable in C++Builder.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top