简体   繁体   English

在C ++ Builder中使用TIdAttachment发送附件

[英]Sending attachment using TIdAttachment in c++ builder

How to send attachment using TIdyAttachment ? 如何使用TIdyAttachment发送附件?

How to convert this TIdAttachment.Create(msg.MessageParts, 'c:\\attach.bmp'); 如何转换此TIdAttachment.Create(msg.MessageParts, 'c:\\attach.bmp'); delphi statement to c++ builder ? delphi声明给C ++ Builder? How to use this abstract class in c++ builder? 如何在C ++ Builder中使用此抽象类? Due to it's being abstract I cannot create an instance of it !!! 由于它是抽象的,因此我无法创建它的实例!

Note that TIdAttachment is indeed abstract (as Remy Lebeau noted in a comment). 请注意, TIdAttachment确实是抽象的(正如Remy Lebeau在评论中指出的那样)。 Use TIdAttachmentFile instead. 请改用TIdAttachmentFile In C++, I guess it should look like (Update: I see you already found that): 在C ++中,我想它应该看起来像(更新:我看到您已经找到了):

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. FWIW,在Delphi中名为TMyClass.Create(args)命名构造函数调用在C ++ Builder中转换为new TMyClass(args) That is why Delphi often overloads Create , instead of using differently named constructors like CreateWithSpecialParams . 这就是为什么Delphi经常重载Create而不是使用名称不同的构造函数(如CreateWithSpecialParams In Delphi, a constructor can have any name, but not in C++. 在Delphi中,构造函数可以具有任何名称,但在C ++中则不能。

Note that in Delphi you can have a constructor Create(Integer) and a constructor CreateEx(Integer) and they are distinguishable. 请注意,在Delphi中,可以有一个constructor Create(Integer)和一个constructor CreateEx(Integer) ,它们是可区分的。 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. 这不能翻译为C ++ Builder,因为两者都翻译为MyClass(int) ,所以如果Delphi程序员希望他或她的类在C ++ Builder中可用,则应避免这样做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM