Thread View: borland.public.cppbuilder.internet.socket
2 messages
2 total messages
Started by MwnN
Thu, 12 Aug 2004 09:48
TIdMappedPop3's IdMappedPop31OutboundData() event
Author: MwnN
Date: Thu, 12 Aug 2004 09:48
Date: Thu, 12 Aug 2004 09:48
38 lines
1874 bytes
1874 bytes
Hi,
I'm trying to edit an email that is being passed throught the
Indys TIdMappedPop3 component.
In the OutboundData() event I can get access to the emails
headers and body via 'AThread->NetData' but I have no idea how
to append the data back to the thread after editing it,or if I
even can, I've tried to do somehting liek the following...
void __fastcall TForm1::IdMappedPop31OutboundData
(TIdMappedPortThread *AThread)
{
if(AnsiContainsText(AThread->NetData, "octets"))
{
AThread->Suspend();
Memo1->Lines->Add(AThread->NetData);
int iStart = Memo1->Lines->IndexOf("Status:"); // start of body
if(iStart!=-1) // edit if found
{
Memo1->Lines->Insert((iStart+1), "Added Text to Email Body");
AThread->NetData = Memo1->Lines->Text;
}
AThread->Resume();
}
}
But it just seems to freeze the program and outlook can't
download the emails at all.
Am I going about this the wrong way or is there someting else
that I need to do in order to edit email bodys.
Thanks again,
MwnN
Re: TIdMappedPop3's IdMappedPop31OutboundData() event
Author: Remy Lebeau (TeamB)
Date: Thu, 12 Aug 2004 17:07
Date: Thu, 12 Aug 2004 17:07
31 lines
2035 bytes
2035 bytes
"MwnN" <MwnN@localhost.com> wrote in message
news:411b3d04$1@newsgroups.borland.com...
> I have no idea how to append the data back to
> the thread after editing it,or if I even can
Simply assign the new data back to the NetData property.
> AThread->Suspend();
There's no need to suspend the thread. In fact, you should not being doing
so. The OnOutboundData event is triggered in the context of the specified
AThread, thus the thread is already blocked while the event handler is
running. If you call Suspend(), you are effectively suspending the event
handler from finishing its work at all.
> Memo1->Lines->Add(AThread->NetData);
> int iStart = Memo1->Lines->IndexOf("Status:"); // start of body
That code is not thread-safe. You cannot safely directly access the GUI
from event handlers that are run within the context of worker threads. You
need to use the thread's Synchronize() method to access the GUI in a
thread-safe manner.
> But it just seems to freeze the program
As well it should, because that is exactly what you are telling it to do.
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