Article View: borland.public.cppbuilder.internet.socket
Article #674Re: Simple Create Attachment() question
From: 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
>
>
Technical Details
Message-ID:
<4770350d$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<477023a5$1@newsgroups.borland.com> <4770320d@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,131c53c1624cdd7c X-Google-Attributes: gid11508e,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: "CharlesLeggette" <charlesleggette@earthlink.net> Newsgroups: borland.public.cppbuilder.internet.socket References: <477023a5$1@newsgroups.borland.com> <4770320d@newsgroups.borland.com> Subject: Re: Simple Create Attachment() question Date: Mon, 24 Dec 2007 16:39:10 -0600 Lines: 89 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3138 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 NNTP-Posting-Host: 66.60.79.20 Message-ID: <4770350d$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1198535949 66.60.79.20 (24 Dec 2007 14:39:09 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail