Wiki Home

Testing Hotmail Reader


Namespace: People
Use this code for testing Hotmail Reader class.
CLEAR
SET MEMOWIDTH TO 120
SET PROC TO HotmailReader

* replace these two constants with valid MSN or Hotmail email and password
#DEFINE ccEmail [email protected]'
#DEFINE ccPwd   'mypassword'

LOCAL hr, nIndex
hr = CreateObject('HotmailReader')

IF Not hr.ConnectTo(ccEmail, ccPwd)
	= MessageBox(hr.statustext + '     ',;
		48, 'Hotmail connection failed')
	RETURN .F.
ENDIF

= MESSAGEB('Connected to Hotmail server.   ' + Chr(13) +;
	'Press OK to display list of folders...   ', 64)

hr.GetMsgFolders()
FOR nIndex=0 TO hr.msgfoldercount-1
	? hr.GetFolderName(nIndex)
ENDFOR

hr.GetFolderMessages('inbox')

IF hr.msgcount = 0
	= MESSAGEB('No messages in Inbox.   ' + Chr(13) +;
		'Press any key to exit... ', 64)
ELSE
	IF MESSAGEB('Messages in Inbox: ' + LTRIM(STR(hr.msgcount)) + Chr(13) +;
		'Press YES to list top Inbox messages...', 64+4) = 6
		FOR nIndex=0 TO MIN(2, hr.msgcount-1)
			hr.GetMessageHeader(nIndex)
			?
			? hr.msgfrom
			? hr.msgsubject
		ENDFOR
	ENDIF
	
	IF MESSAGEB('Press YES to view a message body ...   ', 64+4) = 6
		FOR nIndex=MIN(2, hr.msgcount-1) TO 0 STEP -1
			hr.GetMessage(nIndex)
		ENDFOR

		SET SAFETY OFF
		STRTOFILE(hr.msgbody, 'tmp.$$$')
		SET SAFETY ON
		MODI FILE 'tmp.$$$'

		IF USED('tblHotmailCache') And;
			MESSAGEB('Press YES to view Message Cache...   ', 64+4) = 6
			SELECT tblHotmailCache
			BROW NORMAL
		ENDIF
	ENDIF
ENDIF

Contributor: Anatoliy Mogylevets
( Topic last updated: 2003.09.09 07:01:53 PM )