Search The ForumSearch   RegisterRegister  LoginLogin

MailBee POP3

 AfterLogic Forum : MailBee POP3
Subject Topic: Method Item failed Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
Guest
Guest Group
Guest Group


Joined: 10 November 2003
Online Status: Online
Posts: 262
Posted: 11 November 2005 at 4:26pm | IP Logged Quote Guest

Hi Alex,

I'm getting this error:
"method 'Item' of object 'IMessages' failed"

when I called:

        Dim lngSelectedMsg as Long
        lngSelectedMsg = myGrid.Row
        Set oMsg = oMsgs.Item(lngSelectedMsg)
        txtFrom.Text = oMsg.FromAddr
        txtTo.Text = oMsg.ToAddr
        txtSubj.Text = oMsg.Subject
        txtBody.Text = oMsg.BodyText

I'm trying to display the selected message (from a flexgrid) to the interface. Do you know what causes the problem?

Back to Top View Guest's Profile Search for other posts by Guest
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2206
Posted: 12 November 2005 at 12:05pm | IP Logged Quote Alex

Most likely, lngSelectedMsg index is out of range. For instance, oMsgs.Item(0) will cause an error.

To be valid, the index value passed to Messages.Item method must be in the range 1 to Messages.Count. In other words, Messages collection index is one-based, while myGrid.Row index is probably zero-based.

You may try this:
Code:

Set oMsg = oMsgs.Item(lngSelectedMsg + 1)


Regards,
Alex
Back to Top View Alex's Profile Search for other posts by Alex
 
Guest
Guest Group
Guest Group


Joined: 10 November 2003
Online Status: Online
Posts: 262
Posted: 14 November 2005 at 1:41pm | IP Logged Quote Guest

Hi Alex,

Thanks for your reply. When I run through debug mode, lngSelectedMsg is actually a non-zero. When I click on the second row, the value of lngSelectedMsg is 2, but yet it seems to always fail to pass the line:   

Set oMsg = oMsgs.Item(lngSelectedMsg)

Where can I look at the method 'Item' that contains 'IMessages'? Thanks for your help.

Back to Top View Guest's Profile Search for other posts by Guest
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2206
Posted: 15 November 2005 at 9:52am | IP Logged Quote Alex

Are you sure lngSelectedMsg=2 is valid for the given collection? lngSelectedMsg must be less or equal to oMsgs.Count. If oMsgs contains one or zero messages, oMsgs.Item(2) will fail.

IMessages is an internal name of Messages type. Thus, Item member reference can be found in MailBee documentation at "Reference/Messages Collection/Item Property" topic.

Regards,
Alex
Back to Top View Alex's Profile Search for other posts by Alex
 
Guest
Guest Group
Guest Group


Joined: 10 November 2003
Online Status: Online
Posts: 262
Posted: 18 November 2005 at 2:11pm | IP Logged Quote Guest

You're right. In my code, lngSelectedMsg was initially a Long type, but after many re-uses it was converted to a string type and thus it was giving various errors. Now it works, thanks a lot!

Back to Top View Guest's Profile Search for other posts by Guest
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump

Powered by Web Wiz Forums version 7.9
Copyright ©2001-2004 Web Wiz Guide