I'm trying to attach a file and send it....but the C++ syntax is not very
intuitive..below is a couple of things I've tried without luck...any help
would be appreciated - thanks.
msg->OnCreateAttachment();///this needs parms???
msg->MessageParts->Add()->ContentDescription = "TestFile";
msg->MessageParts->Add()->ContentLocation= "C:\\Ada\\Src\\plan.cpp";//seems
to be right syntax but bombs -- bad pointer????
smtp->Connect("smtpauth.earthlink.net",587);
smtp->Send(msg);
}
catch(Exception *e)
{
::Sleep(1);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::msgCreateAttachment(const TIdMessage *AMsg, const
TStrings *AHeaders, TIdAttachment *&AAttachment)
{
AAttachment->ContentLocation= "C:\\Ada\\Src\\plan.cpp";
AAttachment->ContentDescription = "C:Ada.Src.plan.cpp";
}
//---------------------------------------------------------------------------
Works GREAT!!!!! Thanks.
"Remy Lebeau (TeamB)" wrote in message
news:477044ec$1@newsgroups.borland.com...
>
> "CharlesLeggette" wrote in message
> news:4770350d$1@newsgroups.borland.com...
>
>> Hmm... I get a compiler error
>> [BCC32 Error] Unit1.cpp(29): E2451 Undefined symbol 'TIdAttachmentFile'
>
> #include
>
>
> Gambit
>
>
"CharlesLeggette" wrote in message
news:4770350d$1@newsgroups.borland.com...
> Hmm... I get a compiler error
> [BCC32 Error] Unit1.cpp(29): E2451 Undefined symbol 'TIdAttachmentFile'
#include
Gambit
Hmm... I get a compiler error
[BCC32 Error] Unit1.cpp(29): E2451 Undefined symbol 'TIdAttachmentFile'
[BCC32 Error] Unit1.cpp(29): E2451 Undefined symbol 'attachment'
[BCC32 Error] Unit1.cpp(29): E2303 Type name expected
[BCC32 Error] Unit1.cpp(29): E2379 Statement missing ;
>>>>>>>>>this is offending code ??? am I missing an include file
TIdAttachmentFile *attachment = new
TIdAttachmentFile(msg->MessageParts,"C:\\Ada\\Src\\plan.cpp");
// set attachment's properties as needed...
>>>>>>>>>
here is header list
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include
#include
#include
#include
#include "IdExplicitTLSClientServerBase.hpp"
#include "IdSMTPBase.hpp"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
"Remy Lebeau (TeamB)" wrote in message
news:4770320d@newsgroups.borland.com...
>
> "CharlesLeggette" wrote in message
> news:477023a5$1@newsgroups.borland.com...
>
>> I'm trying to attach a file and send it....but the C++ syntax
>> is not very intuitive..
>
> That is because you are going about it all wrong. You need to instantiate
> a
> TIdAttachmentFile object instead, for example:
>
> TIdAttachmentFile *attachment = new
> TIdAttachmentFile(msg->MessageParts,
> "C:\\Ada\\Src\\plan.cpp");
> // set attachment's properties as needed...
>
>> catch(Exception *e)
>
> Always catch exceptions by (preferrably const) reference, never by
> pointers:
>
> catch(const Exception &e)
>
>> void __fastcall TForm1::msgCreateAttachment(const TIdMessage *AMsg, const
>> TStrings *AHeaders, TIdAttachment *&AAttachment)
>> {
>> AAttachment->ContentLocation= "C:\\Ada\\Src\\plan.cpp";
>> AAttachment->ContentDescription = "C:Ada.Src.plan.cpp";
>> }
>
> The purpose of the OnCreateAttachment event is for you to instantiate your
> own instance of a suitable TIdAttachment-derived class (TIdAttachmentFile,
> TIdAttachmentMemory, or custom class) for a particular file when
> receiving/loading a message, not when sending a message. TIdMessage uses
> TIdAttachmentFile by default for all inbound attachments. For example:
>
> void __fastcall TForm1::msgCreateAttachment(const TIdMessage *AMsg,
> const TStrings *AHeaders, TIdAttachment *&AAttachment)
> {
> // analyze AHeaders as needed...
> AAttachment = new TIdAttachmentMemory(AMsg->MessageParts);
> // or:
> // AAttachment = new TIdAttachmentFile(AMsg->MessageParts);
> // or whatever you need...
> }
>
> The inbound attachment data will then be loaded into the object after the
> event handler exits.
>
>
> Gambit
>
>
Thanks Remy -- and Merry Christmas....
"Remy Lebeau (TeamB)" wrote in message
news:4770320d@newsgroups.borland.com...
>
> "CharlesLeggette" wrote in message
> news:477023a5$1@newsgroups.borland.com...
>
>> I'm trying to attach a file and send it....but the C++ syntax
>> is not very intuitive..
>
> That is because you are going about it all wrong. You need to instantiate
> a
> TIdAttachmentFile object instead, for example:
>
> TIdAttachmentFile *attachment = new
> TIdAttachmentFile(msg->MessageParts,
> "C:\\Ada\\Src\\plan.cpp");
> // set attachment's properties as needed...
>
>> catch(Exception *e)
>
> Always catch exceptions by (preferrably const) reference, never by
> pointers:
>
> catch(const Exception &e)
>
>> void __fastcall TForm1::msgCreateAttachment(const TIdMessage *AMsg, const
>> TStrings *AHeaders, TIdAttachment *&AAttachment)
>> {
>> AAttachment->ContentLocation= "C:\\Ada\\Src\\plan.cpp";
>> AAttachment->ContentDescription = "C:Ada.Src.plan.cpp";
>> }
>
> The purpose of the OnCreateAttachment event is for you to instantiate your
> own instance of a suitable TIdAttachment-derived class (TIdAttachmentFile,
> TIdAttachmentMemory, or custom class) for a particular file when
> receiving/loading a message, not when sending a message. TIdMessage uses
> TIdAttachmentFile by default for all inbound attachments. For example:
>
> void __fastcall TForm1::msgCreateAttachment(const TIdMessage *AMsg,
> const TStrings *AHeaders, TIdAttachment *&AAttachment)
> {
> // analyze AHeaders as needed...
> AAttachment = new TIdAttachmentMemory(AMsg->MessageParts);
> // or:
> // AAttachment = new TIdAttachmentFile(AMsg->MessageParts);
> // or whatever you need...
> }
>
> The inbound attachment data will then be loaded into the object after the
> event handler exits.
>
>
> Gambit
>
>
"CharlesLeggette" wrote in message
news:477023a5$1@newsgroups.borland.com...
> I'm trying to attach a file and send it....but the C++ syntax
> is not very intuitive..
That is because you are going about it all wrong. You need to instantiate a
TIdAttachmentFile object instead, for example:
TIdAttachmentFile *attachment = new TIdAttachmentFile(msg->MessageParts,
"C:\\Ada\\Src\\plan.cpp");
// set attachment's properties as needed...
> catch(Exception *e)
Always catch exceptions by (preferrably const) reference, never by pointers:
catch(const Exception &e)
> void __fastcall TForm1::msgCreateAttachment(const TIdMessage *AMsg, const
> TStrings *AHeaders, TIdAttachment *&AAttachment)
> {
> AAttachment->ContentLocation= "C:\\Ada\\Src\\plan.cpp";
> AAttachment->ContentDescription = "C:Ada.Src.plan.cpp";
> }
The purpose of the OnCreateAttachment event is for you to instantiate your
own instance of a suitable TIdAttachment-derived class (TIdAttachmentFile,
TIdAttachmentMemory, or custom class) for a particular file when
receiving/loading a message, not when sending a message. TIdMessage uses
TIdAttachmentFile by default for all inbound attachments. For example:
void __fastcall TForm1::msgCreateAttachment(const TIdMessage *AMsg,
const TStrings *AHeaders, TIdAttachment *&AAttachment)
{
// analyze AHeaders as needed...
AAttachment = new TIdAttachmentMemory(AMsg->MessageParts);
// or:
// AAttachment = new TIdAttachmentFile(AMsg->MessageParts);
// or whatever you need...
}
The inbound attachment data will then be loaded into the object after the
event handler exits.
Gambit