Antonio Donato
> 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
> 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
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" <esp...@osite.com.br> wrote in message
> 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
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" <esp...@osite.com.br> wrote in message
> 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
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" <esp...@osite.com.br> wrote in message