Skip to main content

[archive] Detecting end of messages

  • July 12, 2006
  • 3 replies
  • 0 views

[Migrated content. Thread originally posted on 12 July 2006]

I am cycling through the unread emails in the outlook inbox with a program that displays the subject and body of each email:


.....
MODIFY olUnreadItems GetFirst() GIVING olMail.
MOVE ZERO TO WS-END.

PERFORM UNTIL WS-END = 1
PERFORM AA-STORE-EMAIL

DISPLAY WS-SUBJECT LINE 4 POS 1
DISPLAY WS-BODY LINE 6 POS 1
ACCEPT WS-DUMMY LINE 8 COL 1

MODIFY olUnreadItems GetNext() GIVING olMail
END-PERFORM.

......
AA-STORE-EMAIL SECTION.
AA-START.
INQUIRE olMail Subject IN WS-SUBJECT.
INQUIRE olMail Body IN WS-BODY.
AA-EXIT.
EXIT.

I have the following exception procedure set up:

DECLARATIVES.
OBJECT-EXCEPTION-HANDLING SECTION.
USE AFTER EXCEPTION ON OBJECT.
OBJECT-EXCEPTION-HANDLER.
MOVE 1 TO WS-END.
END DECLARATIVES.

Unfortunately pressing return to the last unread email on the list just returns the last email again, and doesn't cause the exception procedure to be invoked.

Is there a way of detecting that the last email has been reached? (other than comparing the last and next and checking for changes).

Thanks,
AC.

3 replies

[Migrated content. Thread originally posted on 12 July 2006]

I am cycling through the unread emails in the outlook inbox with a program that displays the subject and body of each email:


.....
MODIFY olUnreadItems GetFirst() GIVING olMail.
MOVE ZERO TO WS-END.

PERFORM UNTIL WS-END = 1
PERFORM AA-STORE-EMAIL

DISPLAY WS-SUBJECT LINE 4 POS 1
DISPLAY WS-BODY LINE 6 POS 1
ACCEPT WS-DUMMY LINE 8 COL 1

MODIFY olUnreadItems GetNext() GIVING olMail
END-PERFORM.

......
AA-STORE-EMAIL SECTION.
AA-START.
INQUIRE olMail Subject IN WS-SUBJECT.
INQUIRE olMail Body IN WS-BODY.
AA-EXIT.
EXIT.

I have the following exception procedure set up:

DECLARATIVES.
OBJECT-EXCEPTION-HANDLING SECTION.
USE AFTER EXCEPTION ON OBJECT.
OBJECT-EXCEPTION-HANDLER.
MOVE 1 TO WS-END.
END DECLARATIVES.

Unfortunately pressing return to the last unread email on the list just returns the last email again, and doesn't cause the exception procedure to be invoked.

Is there a way of detecting that the last email has been reached? (other than comparing the last and next and checking for changes).

Thanks,
AC.
Usually, you can use a count or something like that. I think in this case, there is an "UnreadItemCount" or something like that that you can use. I'm not sure exactly, because I don't know exactly which objects you are referring to.

Of course, another option would be to use the GetLast method and compare it to the one you received using GetNext method. If they are the same, then you are at the end.

Hope this helps.

[Migrated content. Thread originally posted on 12 July 2006]

I am cycling through the unread emails in the outlook inbox with a program that displays the subject and body of each email:


.....
MODIFY olUnreadItems GetFirst() GIVING olMail.
MOVE ZERO TO WS-END.

PERFORM UNTIL WS-END = 1
PERFORM AA-STORE-EMAIL

DISPLAY WS-SUBJECT LINE 4 POS 1
DISPLAY WS-BODY LINE 6 POS 1
ACCEPT WS-DUMMY LINE 8 COL 1

MODIFY olUnreadItems GetNext() GIVING olMail
END-PERFORM.

......
AA-STORE-EMAIL SECTION.
AA-START.
INQUIRE olMail Subject IN WS-SUBJECT.
INQUIRE olMail Body IN WS-BODY.
AA-EXIT.
EXIT.

I have the following exception procedure set up:

DECLARATIVES.
OBJECT-EXCEPTION-HANDLING SECTION.
USE AFTER EXCEPTION ON OBJECT.
OBJECT-EXCEPTION-HANDLER.
MOVE 1 TO WS-END.
END DECLARATIVES.

Unfortunately pressing return to the last unread email on the list just returns the last email again, and doesn't cause the exception procedure to be invoked.

Is there a way of detecting that the last email has been reached? (other than comparing the last and next and checking for changes).

Thanks,
AC.
Usually, you can use a count or something like that. I think in this case, there is an "UnreadItemCount" or something like that that you can use. I'm not sure exactly, because I don't know exactly which objects you are referring to.

Of course, another option would be to use the GetLast method and compare it to the one you received using GetNext method. If they are the same, then you are at the end.

Hope this helps.

[Migrated content. Thread originally posted on 12 July 2006]

I am cycling through the unread emails in the outlook inbox with a program that displays the subject and body of each email:


.....
MODIFY olUnreadItems GetFirst() GIVING olMail.
MOVE ZERO TO WS-END.

PERFORM UNTIL WS-END = 1
PERFORM AA-STORE-EMAIL

DISPLAY WS-SUBJECT LINE 4 POS 1
DISPLAY WS-BODY LINE 6 POS 1
ACCEPT WS-DUMMY LINE 8 COL 1

MODIFY olUnreadItems GetNext() GIVING olMail
END-PERFORM.

......
AA-STORE-EMAIL SECTION.
AA-START.
INQUIRE olMail Subject IN WS-SUBJECT.
INQUIRE olMail Body IN WS-BODY.
AA-EXIT.
EXIT.

I have the following exception procedure set up:

DECLARATIVES.
OBJECT-EXCEPTION-HANDLING SECTION.
USE AFTER EXCEPTION ON OBJECT.
OBJECT-EXCEPTION-HANDLER.
MOVE 1 TO WS-END.
END DECLARATIVES.

Unfortunately pressing return to the last unread email on the list just returns the last email again, and doesn't cause the exception procedure to be invoked.

Is there a way of detecting that the last email has been reached? (other than comparing the last and next and checking for changes).

Thanks,
AC.
olUnreadItems is a collection of exclusively unread items, if you inquire for that collections count, you have the # of unread items.