Thread View: borland.public.cppbuilder.internet.socket
6 messages
6 total messages
Started by CharlesLeggette
Mon, 24 Dec 2007 21:24
Simple Create Attachment() question
Author: CharlesLeggette
Date: Mon, 24 Dec 2007 21:24
Date: Mon, 24 Dec 2007 21:24
25 lines
1874 bytes
1874 bytes
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";
}
//---------------------------------------------------------------------------
Re: Simple Create Attachment() question
Author: Remy Lebeau (TeamB)
Date: Mon, 24 Dec 2007 22:27
Date: Mon, 24 Dec 2007 22:27
48 lines
2640 bytes
2640 bytes
"CharlesLeggette" <charlesleggette@earthlink.net> 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
Re: Simple Create Attachment() question
Author: CharlesLeggette
Date: Mon, 24 Dec 2007 22:30
Date: Mon, 24 Dec 2007 22:30
57 lines
2890 bytes
2890 bytes
Thanks Remy -- and Merry Christmas....
"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message
news:4770320d@newsgroups.borland.com...
>
> "CharlesLeggette" <charlesleggette@earthlink.net> 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
>
>
Re: Simple Create Attachment() question
Author: CharlesLeggette
Date: Mon, 24 Dec 2007 22:39
Date: Mon, 24 Dec 2007 22:39
87 lines
4037 bytes
4037 bytes
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 <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include "IdExplicitTLSClientServerBase.hpp"
#include "IdSMTPBase.hpp"
#include <IdBaseComponent.hpp>
#include <IdComponent.hpp>
#include <IdMessage.hpp>
#include <IdMessageClient.hpp>
#include <IdAttachment.hpp>
#include <IdSMTP.hpp>
#include <IdTCPClient.hpp>
#include <IdTCPConnection.hpp>
#include <IdMessageCoder.hpp>
#include <IdMessageCoderMIME.hpp>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message
news:4770320d@newsgroups.borland.com...
>
> "CharlesLeggette" <charlesleggette@earthlink.net> 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
>
>
Re: Simple Create Attachment() question
Author: Remy Lebeau (TeamB)
Date: Mon, 24 Dec 2007 23:47
Date: Mon, 24 Dec 2007 23:47
11 lines
1288 bytes
1288 bytes
"CharlesLeggette" <charlesleggette@earthlink.net> 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 <IdAttachmentFile.hpp> Gambit
Re: Simple Create Attachment() question
Author: CharlesLeggette
Date: Tue, 25 Dec 2007 02:57
Date: Tue, 25 Dec 2007 02:57
16 lines
1405 bytes
1405 bytes
Works GREAT!!!!! Thanks. "Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message news:477044ec$1@newsgroups.borland.com... > > "CharlesLeggette" <charlesleggette@earthlink.net> 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 <IdAttachmentFile.hpp> > > > Gambit > >
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads