Mega Search
23.2 Million


Sign Up

Make a donation  
Simple Create Attachment() question  
News Group: borland.public.cppbuilder.internet.socket

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";
}
//---------------------------------------------------------------------------



Vote for best question.
Score: 0  # Vote:  0
Date Posted: 24-Dec-2007, at 3:24 PM EST
From: CharlesLeggette
 
Re: Simple Create Attachment() question  
News Group: borland.public.cppbuilder.internet.socket
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
>
> 



Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 24-Dec-2007, at 8:57 PM EST
From: CharlesLeggette
 
Re: Simple Create Attachment() question  
News Group: borland.public.cppbuilder.internet.socket
"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



Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 24-Dec-2007, at 3:47 PM EST
From: Remy Lebeau \(TeamB\)
 
Re: Simple Create Attachment() question  
News Group: borland.public.cppbuilder.internet.socket
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
>
> 



Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 24-Dec-2007, at 4:39 PM EST
From: CharlesLeggette
 
Re: Simple Create Attachment() question  
News Group: borland.public.cppbuilder.internet.socket
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
>
> 



Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 24-Dec-2007, at 4:30 PM EST
From: CharlesLeggette
 
Re: Simple Create Attachment() question  
News Group: borland.public.cppbuilder.internet.socket
"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



Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 24-Dec-2007, at 2:27 PM EST
From: Remy Lebeau \(TeamB\)