BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Indys NNTP Posting problem

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Internet Socket)
View previous topic :: View next topic  
Author Message
MwnN
Guest





PostPosted: Mon Mar 05, 2007 6:53 pm    Post subject: Indys NNTP Posting problem Reply with quote



Hi,

I was wondering what might be wrong with the below code, it runs fine but
there's no message being posted onto the server, plus, is there a was I can
get information back from the Post() method to inform me if it was
successful or failed? as the OnStatus even tells me "Encoding Text" and then
that's it, my thread exits. IdNNTP1WorkEnd() ends with 'wmWrite'

Thanks,
MwnN


IdNNTP2->Username = "********";
IdNNTP2->Password = "********";
IdNNTP2->Host = "my-news-server.com";
IdNNTP2->Port = 119;
IdNNTP2->Connect();

TIdMessage* msg = new TIdMessage(NULL);
TIdEMailAddressList* el = new TIdEMailAddressList(NULL);
TIdEMailAddressItem* ei = new TIdEMailAddressItem(NULL);

ei->Address = "Test (AT) test (DOT) co.uk";
el->EMailAddresses = "Test (AT) test (DOT) co.uk";
msg->ReplyTo = el;
msg->Sender = ei;
msg->From = ei;
msg->Body->Text = "Testing Text Post";
msg->Subject = "Testing Text Post";

IdNNTP2->SelectGroup("0.test");
IdNNTP2->Post(msg);

delete msg;
delete el;
delete ei;
IdNNTP2->Disconnect();
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Tue Mar 06, 2007 12:19 am    Post subject: Re: Indys NNTP Posting problem Reply with quote



"MwnN" <MwnN (AT) localhost (DOT) com> wrote in message
news:1NOdncmTj_xWj3HYRVnygAA (AT) giganews (DOT) com...

Quote:
I was wondering what might be wrong with the below code, it
runs fine but there's no message being posted onto the server

Is there an exception being thrown? If not, then the message is
guaranteed to be posted.

Quote:
is there a was I can get information back from the Post() method to
inform me if it was successful or failed?

If no exception is thrown, then it was successful.

Quote:
the OnStatus even tells me "Encoding Text" and then that's it, my
thread exits.


Then an exception is likely being thrown that you are not catching.
You should be wrapping your code in try..catch blocks, ie:

IdNNTP2->Username = "********";
IdNNTP2->Password = "********";
IdNNTP2->Host = "my-news-server.com";
IdNNTP2->Port = 119;

try
{
TIdMessage* msg = new TIdMessage(NULL);
try
{
msg->ReplyTo->EMailAddresses = "Test (AT) test (DOT) co.uk";
msg->From->Address = "Test (AT) test (DOT) co.uk";
msg->Body->Text = "Testing Text Post";
msg->Subject = "Testing Text Post";

IdNNTP2->Connect();
try
{
IdNNTP2->SelectGroup("0.test");
IdNNTP2->Post(msg);
}
__finally
{
IdNNTP2->Disconnect();
}
}
__finally
{
delete msg;
}
}
catch(const Exception &)
{
// error posting the message, do something
}


Gambit
Back to top
MwnN
Guest





PostPosted: Tue Mar 06, 2007 3:15 am    Post subject: Re: Indys NNTP Posting problem Reply with quote



"Remy Lebeau (TeamB)" wrote in message
news:45ec673b (AT) newsgroups (DOT) borland.com...
Quote:


Then an exception is likely being thrown that you are not catching.
You should be wrapping your code in try..catch blocks, ie:


Gambit


Hey Gambit,

I was using a try catch block in my code but nothing came up, so I decided
to test on the borland.test group news server and I got the exception, very
strange!!

I needed to call

msg->NewsGroups->Add("borland.public.test");

first inorder for it to post on the newsgroups.borland.com server, however,
when logging into my nntp server with a username/password to
news-europe.giganews.com the exception never happened and nothing was
posted, calling the line above to add the group fist worked on my news
server too which enabled posting, any ideas as to why the group is needed,
this could make things messy if the group is removed form the server, having
to redownload the full list again to verify groups, but at least the
exception was thrown on both news servers that no such group existed.

Thanks again Gambit!
Back to top
MwnN
Guest





PostPosted: Tue Mar 06, 2007 3:47 am    Post subject: Re: Indys NNTP Posting problem Reply with quote

Any idea as to why when posting on different times, with the same settings
my messages are becoming child messages of the first post and not new root
messages as you might say on the news server?

-Test Message
Test Message
Test Message
Test Message
Test Message
Test Message

instead of

- Test Message
- Test Message
- Test Message
- Test Message
- Test Message


Thanks,
MwnN
Back to top
MwnN
Guest





PostPosted: Wed Mar 07, 2007 4:20 am    Post subject: Re: Indys NNTP Posting problem Reply with quote

"Remy Lebeau (TeamB)" wrote in message
news:45ec673b (AT) newsgroups (DOT) borland.com...
Quote:


Then an exception is likely being thrown that you are not catching.
You should be wrapping your code in try..catch blocks, ie:


Gambit


Hey Gambit,

I was using a try catch block in my code but nothing came up, so I decided
to test on the borland.test group news server and I got the exception, very
strange!!

I needed to call

msg->NewsGroups->Add("borland.public.test");

first inorder for it to post on the newsgroups.borland.com server, however,
when logging into my nntp server with a username/password to
news-europe.giganews.com the exception never happened and nothing was
posted, calling the line above to add the group fist worked on my news
server too which enabled posting, any ideas as to why the group is needed,
this could make things messy if the group is removed form the server, having
to redownload the full list again to verify groups, but at least the
exception was thrown on both news servers that no such group existed.

Thanks again Gambit!

Also,

Any idea as to why when posting on different times, with the same settings
my messages are becoming child messages of the first post and not new root
messages as you might say on the news server?

-Test Message
Test Message
Test Message
Test Message
Test Message
Test Message

instead of

- Test Message
- Test Message
- Test Message
- Test Message
- Test Message


Thanks,
MwnN
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Wed Mar 07, 2007 5:46 am    Post subject: Re: Indys NNTP Posting problem Reply with quote

"MwnN" <MwnN (AT) localhost (DOT) com> wrote in message
news:45ede924$1 (AT) newsgroups (DOT) borland.com...

Quote:
I was using a try catch block in my code but nothing came up

Then no error was occuring. The message was successfully being
delivered to the server. Maybe you simply were not refreshing your
reader?

Quote:
I needed to call

msg->NewsGroups->Add("borland.public.test");

first inorder for it to post on the newsgroups.borland.com server

That makes sense. Even though the server knows the specific newsgroup
the client is posting to, the message itself still has to specify the
newsgroup(s) as well.

Quote:
any ideas as to why the group is needed

Because NNTP servers require it.

Quote:
this could make things messy if the group is removed form the
server, having to redownload the full list again to verify groups

No, it does not. You know the group you are posting to, so simply
ensure that the group exists in the message header before posting it.
You don't have to verify anything on the server. And if the group
disappears from the server, its messages disappear with it anyway.


Gambit
Back to top
Mark Jacobs
Guest





PostPosted: Wed Mar 07, 2007 8:00 pm    Post subject: Re: Indys NNTP Posting problem Reply with quote

Nothing seems to be maintaining the "References" value in the news message
header. Does Indy handle this automatically, or do you need to add code like
:-

Set NNTP Message Header section References to References plus Message-ID of
what you're repying to?
--
Mark Jacobs
DK Computing
http://www.dkcomputing.co.uk
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Wed Mar 07, 2007 11:54 pm    Post subject: Re: Indys NNTP Posting problem Reply with quote

"Mark Jacobs" <http://www.jacobsm.com/mjmsg.htm?BorlandNG> wrote in
message news:45eec52d (AT) newsgroups (DOT) borland.com...

Quote:
Nothing seems to be maintaining the "References" value in the
news message header.

That is not Indy's responsibilty to manage. You have to do that in
your own code, since only you know which messages you are posting
replies to.

Quote:
Does Indy handle this automatically

No.

Quote:
or do you need to add code like :-

Yes.


Gambit
Back to top
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Internet Socket) All times are GMT
Page 1 of 1

 
 


Powered by phpBB © 2001, 2006 phpBB Group
.