🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.internet.socket
9 messages
9 total messages Started by Antonio Donato Sat, 26 Jun 2004 19:35
Attachments with TIdMessage
#5630
Author: Antonio Donato
Date: Sat, 26 Jun 2004 19:35
9 lines
1301 bytes
I am trying to send an attachment in an application thar has a TIdSMTP
and a TIdMessage by Borland C++5. In the properties of Message there are
Body, Subject, CCList and others, but no Attachment property. The book
Indy in Depth does not tell about attachments. Hwever, to send an
attachment must be a very simple thing. Can someone explain me how to do
it? I also found two articles in Dephi about it, but unhappily I do not
understand Delphy, only CB++. Thank all you.

Antonio Donato
Re: Attachments with TIdMessage
#5631
Author: Remy Lebeau (TeamB)
Date: Sat, 26 Jun 2004 23:04
17 lines
1334 bytes
"Antonio Donato" <espvida@osite.com.br> wrote in message
news:40DDCFFC.539C4C06@osite.com.br...

> In the properties of Message there are Body, Subject,
> CCList and others, but no Attachment property.

You need to add a TIdAttachment instance to the MessageParts collection, ie:

    TIdAttachment *attachment = new TIdAttachment(IdMessage1, "c:\\path
to\\file.ext");
    attachment->FileName = "file.ext";
    attachment->ContentType = "whatever";
    // etc...


Gambit
Re: Attachments with TIdMessage
#5632
Author: Antonio Donato
Date: Sun, 27 Jun 2004 03:48
29 lines
1681 bytes
> Dear Remy,
>
> I compiled that code below and the result was:
>
>
>   Could not find a match for 'TIdAttachment::TIdAttachment(TIdMessage *, char")'
>
>
> If you know what is this I thank you very much. Thanks.
>
> Antonio Donato
>
"Remy Lebeau (TeamB)" ha escrito:

> "Antonio Donato" <espvida@osite.com.br> wrote in message
> news:40DDCFFC.539C4C06@osite.com.br...
>
> > In the properties of Message there are Body, Subject,
> > CCList and others, but no Attachment property.
>
> You need to add a TIdAttachment instance to the MessageParts collection, ie:
>
>     TIdAttachment *attachment = new TIdAttachment(IdMessage1, "c:\\path
> to\\file.ext");
>     attachment->FileName = "file.ext";
>     attachment->ContentType = "whatever";
>     // etc...
>
> Gambit
Re: Attachments with TIdMessage
#5633
Author: Remy Lebeau (TeamB)
Date: Sun, 27 Jun 2004 04:55
14 lines
1296 bytes
"Antonio Donato" <espvida@osite.com.br> wrote in message
news:40DE437D.F599902C@osite.com.br...

> I compiled that code below and the result was:
>
>
>   Could not find a match for 'TIdAttachment::TIdAttachment(TIdMessage *,
char")'

Please show your actual code.


Gambit
Re: Attachments with TIdMessage
#5634
Author: Antonio Donato
Date: Sun, 27 Jun 2004 23:32
107 lines
3554 bytes
Dear Remy Lebeau,

the code is the following. Note that I did not found at Compenent Palette at
BC++5 in which I installed Indy any icon to TIdAttachment, but there are in it
Icons for TIdMessage and TIdSMTP, which I put in application form. Absence of
TIdAttachment in Component Palette in BC++ is something correct or wrong?

I thank you very much for all your and any other's attention.

Antonio Donato



> IndyMessage->From->Name=AnsiString(NameMailTag);
> IndyMessage->From->Address=AnsiString(ReturnMailTag);
> IndyMessage->Recipients->EMailAddresses=AnsiString(ToMailTag);
> IndyMessage->CCList->EMailAddresses=AnsiString(CCMailTag);
> IndyMessage->BccList->EMailAddresses=AnsiString(CCOMailTag);
> IndyMessage->Subject=AnsiString(SubjectMailTag);
>
> IndySMTP->Host=AnsiString(SMTPMailTag);
> IndySMTP->Username=AnsiString(LoginMailTag);
> IndySMTP->Password=AnsiString(PasswordMailTag);
> IndySMTP->AuthenticationType=atLogin;
>
>
> strcpy(AttachTag, MailForm->AttachEdit->Text.c_str());
>
> outfp=fopen(TmpFileAddress, "w");
> fclose(outfp);
>
> RichEdit->PlainText=true;
> RichEdit->Lines->SaveToFile(AnsiString(TmpFileAddress));
> IndyMessage->Body->LoadFromFile(AnsiString(TmpFileAddress));
>
> if(AttachTag[0]!=0)
> {
> TIdAttachment *attachment = new TIdAttachment(IndyMessage, AttachTag);
> attachment->FileName = "file.zip";
> }
>
>
> TCursor oldCursor = Screen->Cursor;
> Screen->Cursor = crHourGlass;
> Application->ProcessMessages();
>
>
> try
> {
> IndySMTP->Connect(-1);
> }
>
> catch(...)
> {
> sprintf(textlabel, "Impossible to connect.");
> OKDialog->DialogLabel->Caption = AnsiString(textlabel);
> OKDialog->Caption = "Message Box";
> OKDialog->ShowModal();
>
> IndySMTP->Disconnect();
> Screen->Cursor = oldCursor;
> Close();
> return;
> }
>
>
> try
> {
> IndySMTP->Send(IndyMessage);
> }
>
> catch(...)
> {
> sprintf(textlabel, "Impossible to send");
> OKDialog->DialogLabel->Caption = AnsiString(textlabel);
> OKDialog->Caption = "Message Box";
> OKDialog->ShowModal();
>
> IndySMTP->Disconnect();
> Screen->Cursor = oldCursor;
> return;
> }
>
> IndySMTP->Disconnect();
>
> Screen->Cursor = oldCursor;
>
>





"Remy Lebeau (TeamB)" ha escrito:

> "Antonio Donato" <espvida@osite.com.br> wrote in message
> news:40DE437D.F599902C@osite.com.br...
>
> > I compiled that code below and the result was:
> >
> >
> >   Could not find a match for 'TIdAttachment::TIdAttachment(TIdMessage *,
> char")'
>
> Please show your actual code.
>
> Gambit
Re: Attachments with TIdMessage
#5635
Author: Remy Lebeau (TeamB)
Date: Mon, 28 Jun 2004 01:21
42 lines
2294 bytes
"Antonio Donato" <espvida@osite.com.br> wrote in message
news:40DF591C.96CFDE8A@osite.com.br...

> the code is the following.

> Note that I did not found at Compenent Palette at
> BC++5 in which I installed Indy any icon to
> TIdAttachment

TIdAttachment is not a component to begin with, thus it does not appear in
the Component Palette.

> but there are in it Icons for TIdMessage and TIdSMTP

Those, on the other hand, ae actual components, thus they appear in the
Palette.

> Absence of TIdAttachment in Component Palette in
> BC++ is something correct or wrong?

TIdAttachment is not a component, thus you have to instantiate in code, not
visually at design-time.  I already gave you the code to do that.

> > RichEdit->PlainText=true;
> > RichEdit->Lines->SaveToFile(AnsiString(TmpFileAddress));
> > IndyMessage->Body->LoadFromFile(AnsiString(TmpFileAddress));

You could do the following instead, then you don't need the temporary file
anymore:

    IndyMessage->Body->Assign(RichEdit->Lines);

> > TIdAttachment *attachment = new TIdAttachment(IndyMessage, AttachTag);

That should be this instead:

    TIdAttachment *attachment = new TIdAttachment(IndyMessage->MessageParts,
AttachTag);


Gambit
Re: Attachments with TIdMessage
#5636
Author: Antonio Donato
Date: Mon, 28 Jun 2004 05:12
50 lines
2592 bytes
Dear Remy,

thank you very much, it was done! Let me ask a further question, if we must send
more than one attached in a same e-mail, is it possible with TIdAttachment, and
what would be the code?

Antonio Donato

"Remy Lebeau (TeamB)" ha escrito:

> "Antonio Donato" <espvida@osite.com.br> wrote in message
> news:40DF591C.96CFDE8A@osite.com.br...
>
> > the code is the following.
>
> > Note that I did not found at Compenent Palette at
> > BC++5 in which I installed Indy any icon to
> > TIdAttachment
>
> TIdAttachment is not a component to begin with, thus it does not appear in
> the Component Palette.
>
> > but there are in it Icons for TIdMessage and TIdSMTP
>
> Those, on the other hand, ae actual components, thus they appear in the
> Palette.
>
> > Absence of TIdAttachment in Component Palette in
> > BC++ is something correct or wrong?
>
> TIdAttachment is not a component, thus you have to instantiate in code, not
> visually at design-time.  I already gave you the code to do that.
>
> > > RichEdit->PlainText=true;
> > > RichEdit->Lines->SaveToFile(AnsiString(TmpFileAddress));
> > > IndyMessage->Body->LoadFromFile(AnsiString(TmpFileAddress));
>
> You could do the following instead, then you don't need the temporary file
> anymore:
>
>     IndyMessage->Body->Assign(RichEdit->Lines);
>
> > > TIdAttachment *attachment = new TIdAttachment(IndyMessage, AttachTag);
>
> That should be this instead:
>
>     TIdAttachment *attachment = new TIdAttachment(IndyMessage->MessageParts,
> AttachTag);
>
> Gambit
Re: Attachments with TIdMessage
#5637
Author: Remy Lebeau (TeamB)
Date: Mon, 28 Jun 2004 05:22
15 lines
1424 bytes
"Antonio Donato" <espvida@osite.com.br> wrote in message
news:40DFA8CA.7A13AA@osite.com.br...

> if we must send more than one attached in a same e-mail,
> is it possible with TIdAttachment

Yes.  You simply create more TIdAttachment instances.

> and what would be the code?

You already have that code.


Gambit
Re: Attachments with TIdMessage
#5642
Author: Antonio Donato
Date: Mon, 28 Jun 2004 17:36
22 lines
1616 bytes
Dear Remy,

It's all OK, all was perfectly done. I have to thank you for your help
and for your readness in doing so.

Antonio Donato

"Remy Lebeau (TeamB)" ha escrito:

> "Antonio Donato" <espvida@osite.com.br> wrote in message
> news:40DFA8CA.7A13AA@osite.com.br...
>
> > if we must send more than one attached in a same e-mail,
> > is it possible with TIdAttachment
>
> Yes.  You simply create more TIdAttachment instances.
>
> > and what would be the code?
>
> You already have that code.
>
> 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