[Migrated content. Thread originally posted on 07 July 2006]
Hi,Trying to write a simple bit of code to get a count of the number of unread emails in Outlook. Have got this far:
77 olApp HANDLE OF Application.
77 olNs HANDLE OF Namespace.
77 olItem HANDLE OF ContactItem.
77 olAppt HANDLE OF AppointmentItem.
77 olMail HANDLE OF MailItem.
77 olAttach HANDLE OF Attachments.
77 olInbox HANDLE OF Items.
01 WS-COUNT PIC S9(9) COMP-5.
PROCEDURE DIVISION.
A-GET-INBOX SECTION.
AA-START.
*******************************************************************
With T*is
* .oOutlook = Create(OUTLOOK_CLSID)
*
* .oSpace = .oOutlook.GetNameSpace('Mapi')
*
* .oInbox = .oSpace.GetDefaultFolder(6)
*
* If .oInbox.Items.Count
* Wait Window 'No new messages.' Nowait
* Return
* Endif
* .oMsg = .oInbox.Items(.oInbox.Items.Count)
* For Each .oMsg In .oInbox.Items
*
* lcSenderName = .oMsg.SenderName,;
* lcSubject = .oMsg.subject
* lcHTMLBody = .oMsg.HTMLbody
* lcTextBody = .oMsg.body,;
* lcEntryId = .oMsg.EntryId
* ltReceived = .oMsg.ReceivedTime,;
* ltSentOn = .oMsg.SentOn
*
* * place code here to save data in a table
* Next
Endwit*
**********************************************************************
display standard window
SH3125 title "Inbox"
user-colors
background-low
auto-minimize
auto-resize.
*Open the Outlook object (hooking into, if already running)
CREATE Application OF Outlook
HANDLE IN olApp.
MODIFY olApp GetNameSpace("MAPI")
GIVING olNs.
MODIFY olNs Logon().
MODIFY olNs GetDefaultFolder(6)
GIVING olInbox.
INQUIRE olInbox count IN WS-COUNT.
DISPLAY WS-COUNT.
DESTROY olNs.
DESTROY olApp.
AA-EXIT.
EXIT.
I have included within the cobol the code I am trying to translate into cobol.
This compiles but doesn't work.
Any help would be greatly appreciated.



