Article View: borland.public.cppbuilder.internet.socket
Article #672Re: Simple Create Attachment() question
From: 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
>
>
Technical Details
Message-ID:
<4770331d$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.germany.com!newsfeed01.sul.t-online.de!t-online.de!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:30:55 -0600 Lines: 59 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: <4770331d$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1198535453 66.60.79.20 (24 Dec 2007 14:30:53 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.germany.com!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail