' ########################################################################################
' Microsoft Windows
' File: msoeapi.inc
' Copyright (c) 2011 Jos? Roca
' Portions Copyright (c) Microsoft Corporation.
' All Rights Reserved.
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
' EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
' MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
' ########################################################################################
' ########################################################################################
' Deprecated. Do not use.
' Outlook Express and Windows Mail have been replaced with Windows Live.
' ########################################################################################
#IF NOT %DEF(PBX_msoeapi_PBI)
#DEFINE PBX_msoeapi_PBI
%EQUATE `MSOEAPI_INC = 1
#INCLUDE ONCE "Legacy/COM/ObjIdl.inc"
#INCLUDE ONCE "Legacy/COM/mimeole.inc"
'//+-------------------------------------------------------------------------
'// GUID Definitions
'//--------------------------------------------------------------------------
$CLSID_OutlookExpress = GUID$("{3338DF69-4660-11D1-8A8D-00C04FB951F3}")
$CLSID_Envelope = GUID$("{0006F01A-0000-0000-C000-000000000046}")
$CLSID_StoreNamespace = GUID$("{E70C92A9-4BFD-11D1-8A95-00C04FB951F3}")
$IID_IOutlookExpress = GUID$("{3338DF6A-4660-11D1-8A8D-00C04FB951F3}")
$IID_IStoreNamespace = GUID$("{E70C92AA-4BFD-11D1-8A95-00C04FB951F3}")
$IID_IStoreFolder = GUID$("{E70C92AC-4BFD-11D1-8A95-00C04FB951F3}")
'//+-------------------------------------------------------------------------
'// Errors Definition Macros
'// Also defined in mimeole.inc
'//--------------------------------------------------------------------------
#IF NOT %DEF(%FACILITY_INTERNET)
%EQUATE `FACILITY_INTERNET = 12
#ENDIF
#IF NOT %DEF(%HR_E_DEFINED)
%EQUATE `HR_E_DEFINED = 1
MACRO HR_E(n) = MAKE_SCODE(%SEVERITY_ERROR, %FACILITY_INTERNET, n)
#ENDIF
#IF NOT %DEF(%HR_S_DEFINED)
%EQUATE `HR_S_DEFINED = 1
MACRO HR_S(n) = MAKE_SCODE(%SEVERITY_ERROR, %FACILITY_INTERNET, n)
#ENDIF
#IF NOT %DEF(%HR_CODE_DEFINED)
%EQUATE `HR_CODE_DEFINED = 1
MACRO HR_CODE(hr) = (hr AND &Hffff)
#ENDIF
'//+-------------------------------------------------------------------------
'// MSOEAPI Failure Return Values
'//--------------------------------------------------------------------------
%EQUATE `MSOEAPI_E_FILE_NOT_FOUND = &HFFFFCF65 ' HR_E(0xCF65)
%EQUATE `MSOEAPI_E_STORE_INITIALIZE = &HFFFFCF66 ' HR_E(0xCF66)
%EQUATE `MSOEAPI_E_INVALID_STRUCT_SIZE = &HFFFFCF67 ' HR_E(0xCF67)
%EQUATE `MSOEAPI_E_CANT_LOAD_MSOERT = &HFFFFCF68 ' HR_E(0xCF68)
%EQUATE `MSOEAPI_E_CANT_LOAD_INETCOMM = &HFFFFCF69 ' HR_E(0xCF69)
%EQUATE `MSOEAPI_E_CANT_LOAD_MSOEACCT = &HFFFFCF70 ' HR_E(0xCF70)
%EQUATE `MSOEAPI_E_CANT_MSOERT_BADVER = &HFFFFCF71 ' HR_E(0xCF71)
%EQUATE `MSOEAPI_E_CANT_INETCOMM_BADVER = &HFFFFCF72 ' HR_E(0xCF72)
%EQUATE `MSOEAPI_E_CANT_MSOEACCT_BADVER = &HFFFFCF73 ' HR_E(0xCF73)
'//+-------------------------------------------------------------------------
'// String Definition Macros
'//--------------------------------------------------------------------------
'#ifndef STRCONSTA
'#ifdef DEFINE_STRCONST
'#define STRCONSTA(x,y) EXTERN_C const char x[] = y
'#define STRCONSTW(x,y) EXTERN_C const WCHAR x[] = L##y
'#else
'#define STRCONSTA(x,y) EXTERN_C const char x[]
'#define STRCONSTW(x,y) EXTERN_C const WCHAR x[]
'#endif STRCONSTA
'#endif
'//+-------------------------------------------------------------------------
'// Strings
'//--------------------------------------------------------------------------
$STR_MSOEAPI_INSTANCECLASS = "OutlookExpressHiddenWindow" ' STRCONSTA(STR_MSOEAPI_INSTANCECLASS, "OutlookExpressHiddenWindow");
$STR_MSOEAPI_IPSERVERCLASS = "OutlookExpressInProccessServer" ' STRCONSTA(STR_MSOEAPI_IPSERVERCLASS, "OutlookExpressInProccessServer");
$STR_MSOEAPI_INSTANCEMUTEX = "OutlookExpress_InstanceMutex_101897" ' STRCONSTA(STR_MSOEAPI_INSTANCEMUTEX, "OutlookExpress_InstanceMutex_101897");
$STR_MSOEAPI_DLLNAME = "MSOE.DLL" ' STRCONSTA(STR_MSOEAPI_DLLNAME, "MSOE.DLL");
$STR_MSOEAPI_START = "CoStartOutlookExpress" ' STRCONSTA(STR_MSOEAPI_START, "CoStartOutlookExpress");
$STR_MSOEAPI_SHUTDOWN = "CoShutdownOutlookExpress" ' STRCONSTA(STR_MSOEAPI_SHUTDOWN, "CoShutdownOutlookExpress");
$STR_MSOEAPI_CREATE = "CoCreateOutlookExpress" ' STRCONSTA(STR_MSOEAPI_CREATE, "CoCreateOutlookExpress");
'//+-------------------------------------------------------------------------
'// Function Typedefs
'//--------------------------------------------------------------------------
'typedef HRESULT (APIENTRY *PFNSTART)(DWORD dwFlags, LPCSTR pszCmdLine, INT nCmdShow);
'typedef HRESULT (APIENTRY *PFNSHUTDOWN)(DWORD dwReserved);
'typedef HRESULT (APIENTRY *PFNCREATE)(IUnknown *pUnkOuter, IUnknown **ppUnknown);
%EQUATE `MSOEAPI_ACDM_CMDLINE = 1
%EQUATE `MSOEAPI_ACDM_NOTIFY = 2
%EQUATE `MSOEAPI_ACDM_ODBNOTIFY = 3
%EQUATE `MSOEAPI_ACDM_STGNOTIFY = 4
'#ifndef OE5_BETA2
'TYPE HENUMSTORE
' unused AS DWORD
'END TYPE
'#endif // OE5_BETA2
#IF NOT %DEF(%IOutlookExpress_INTERFACE_DEFINED)
%EQUATE `IOutlookExpress_INTERFACE_DEFINED = 1
%EQUATE `MSOEAPI_START_SHOWSPLASH = &H00000001
%EQUATE `MSOEAPI_START_MESSAGEPUMP = &H00000002
%EQUATE `MSOEAPI_START_ALLOWCOMPACTION = &H00000004
%EQUATE `MSOEAPI_START_INSTANCEMUTEX = &H00000008
%EQUATE `MSOEAPI_START_SHOWERRORS = &H00000010
%EQUATE `MSOEAPI_START_APPWINDOW = &H00000020
%EQUATE `MSOEAPI_START_DEFAULTIDENTITY = &H00000040
%EQUATE `MSOEAPI_START_APPLICATION = %MSOEAPI_START_SHOWSPLASH OR %MSOEAPI_START_SHOWERRORS OR %MSOEAPI_START_MESSAGEPUMP OR %MSOEAPI_START_ALLOWCOMPACTION OR %MSOEAPI_START_INSTANCEMUTEX OR %MSOEAPI_START_APPWINDOW
%EQUATE `MSOEAPI_START_COMOBJECT = %MSOEAPI_START_SHOWERRORS
' ########################################################################################
' Interface name = IOutlookExpress
' IID = 3338DF6A-4660-11d1-8A8D-00C04FB951F3
' Inherited interface = IUnknown
' ########################################################################################
INTERFACE IOutlookExpress $IID_IOutlookExpress
 INHERIT IUnknown
 ' =====================================================================================
 METHOD Start ( ' VTable offset = 12
 BYVAL dwFlags AS DWORD
 , BYREF pszCmdLine AS ASCIIZ
 , BYVAL nCmdShow AS LONG
 ) AS LONG
 ' =====================================================================================
END INTERFACE
#ENDIF ' /* __IOutlookExpress_INTERFACE_DEFINED__ */
#IF NOT %DEF(%IStoreNamespace_INTERFACE_DEFINED)
%EQUATE `IStoreNamespace_INTERFACE_DEFINED = 1
'typedef DWORD STOREFOLDERID;
%EQUATE `FOLDERID_ROOT = 0
%EQUATE `FOLDERID_INVALID = &HFFFFFFFF
'typedef DWORD MESSAGEID;
%EQUATE `MESSAGEID_INVALID = &HFFFFFFFF
%EQUATE `MESSAGEID_FIRST = &HFFFFFFFF
%EQUATE `CCHMAX_FOLDER_NAME = 256
%EQUATE `WM_FOLDERNOTIFY = %WM_USER + 1600 ' // IStoreNamespace Notification - lparam=LPFOLDERNOTIFYEX, client must call CoTaskMemFree(lParam)
%EQUATE `WM_NEWMSGS = %WM_USER + 1650 ' // IStoreFolder Notification: wParam=MESSAGEID, lParam=Reserved
%EQUATE `WM_DELETEMSGS = %WM_USER + 1651 ' // IStoreFolder Notification: wParam=prgdwMsgId, lParam=cMsgs
%EQUATE `WM_DELETEFOLDER = %WM_USER + 1652 ' // IStoreFolder Notification: wParam=STOREFOLDERID or HFOLDER
%EQUATE `WM_MARKEDASREAD = %WM_USER + 1653 ' // IStoreFolder Notification: wParamprgdwMsgId, lParam=cMsgs
%EQUATE `WM_MARKEDASUNREAD = %WM_USER + 1654 ' // IStoreFolder Notification: wParamprgdwMsgId, lParam=cMsgs
' FOLDERNOTIFYTYPE enum
%EQUATE `NEW_FOLDER = 1
%EQUATE `DELETE_FOLDER = %NEW_FOLDER + 1
%EQUATE `RENAME_FOLDER = %DELETE_FOLDER + 1
%EQUATE `MOVE_FOLDER = %RENAME_FOLDER + 1
%EQUATE `UNREAD_CHANGE = %MOVE_FOLDER + 1
%EQUATE `IMAPFLAG_CHANGE = %UNREAD_CHANGE + 1
%EQUATE `UPDATEFLAG_CHANGE = %IMAPFLAG_CHANGE + 1
%EQUATE `FOLDER_PROPS_CHANGED = %UPDATEFLAG_CHANGE + 1
' // Size = 12 bytes
TYPE FOLDERNOTIFYEX DWORD
 ntype AS LONG ' // FOLDERNOTIFYTYPE enum
 idFolderOld AS DWORD ' // STOREFOLDERID
 idFolderNew AS DWORD ' // STOREFOLDERID
END TYPE
' // Size = 12 bytes
TYPE MESSAGEIDLIST DWORD
 cbSize AS DWORD
 cMsgs AS DWORD
 prgdwMsgId AS DWORD ' // LPMESSAGEID - Array of message identifier (ID) values
END TYPE
' SPECIALFOLDER enum
%EQUATE `FOLDER_NOTSPECIAL = -1
%EQUATE `FOLDER_INBOX = %FOLDER_NOTSPECIAL + 1
%EQUATE `FOLDER_OUTBOX = %FOLDER_INBOX + 1
%EQUATE `FOLDER_SENT = %FOLDER_OUTBOX + 1
%EQUATE `FOLDER_DELETED = %FOLDER_SENT + 1
%EQUATE `FOLDER_DRAFT = %FOLDER_DELETED + 1
%EQUATE `FOLDER_MAX = %FOLDER_DRAFT + 1
' // Size = 280 bytes
TYPE FOLDERPROPS DWORD
 cbSize AS DWORD
 dwFolderId AS DWORD ' // STOREFOLDERID
 cSubFolders AS LONG
 sfType AS LONG ' // SPECIALFOLDER
 cUnread AS DWORD
 cMessage AS DWORD
 szName AS ASCIIZ * %CCHMAX_FOLDER_NAME
END TYPE
' // CLocalStore::CopyMoveMessages flags - dwFlags == 0 is copy
%EQUATE `CMF_MOVE = &H0001 ' // msgs deleted from src fldr after copy
%EQUATE `CMF_DELETE = &H0002 ' // same as CMF_MOVE but uses delete string for status
' ########################################################################################
' Interface name = IStoreNamespace
' IID = E70C92AA-4BFD-11d1-8A95-00C04FB951F3
' Inherited interface = IUnknown
' ########################################################################################
INTERFACE IStoreNamespace $IID_IStoreNamespace
 INHERIT IUnknown
 ' =====================================================================================
 METHOD Initialize ( ' VTable offset = 12
 BYVAL hwndOwner AS DWORD
 , BYVAL dwReserved AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetDirectory ( ' VTable offset = 16
 BYREF pszPath AS ASCIIZ
 , BYVAL cchMaxPath AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD OpenSpecialFolder ( ' VTable offset = 20
 BYVAL sfType AS LONG
 , BYVAL dwReserved AS DWORD
 , BYREF ppFolder AS IStoreFolder
 ) AS LONG
 ' =====================================================================================
 METHOD OpenFolder ( ' VTable offset = 24
 BYVAL dwFolderId AS LONG
 , BYVAL dwReserved AS DWORD
 , BYREF ppFolder AS IStoreFolder
 ) AS LONG
 ' =====================================================================================
 METHOD CreateFolder ( ' VTable offset = 28
 BYVAL dwParentId AS LONG
 , BYREF pszName AS ASCIIZ
 , BYVAL dwReserved AS DWORD
 , BYREF pdwFolderId AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD RenameFolder ( ' VTable offset = 32
 BYVAL dwFolderId AS LONG
 , BYVAL dwReserved AS DWORD
 , BYREF pszNewName AS ASCIIZ
 ) AS LONG
 ' =====================================================================================
 METHOD MoveFolder ( ' VTable offset = 36
 BYVAL dwFolderId AS LONG
 , BYVAL dwParentId AS LONG
 , BYVAL dwReserved AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD DeleteFolder ( ' VTable offset = 40
 BYVAL dwFolderId AS LONG
 , BYVAL dwReserved AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetFolderProps ( ' VTable offset = 44
 BYVAL dwFolderId AS LONG
 , BYVAL dwReserved AS DWORD
 , BYREF pProps AS FOLDERPROPS
 ) AS LONG
 ' =====================================================================================
 METHOD CopyMoveMessages ( ' VTable offset = 48
 BYVAL pSource AS IStoreFolder
 , BYVAL pDest AS IStoreFolder
 , BYREF pMsgIdList AS MESSAGEIDLIST
 , BYVAL dwFlags AS DWORD
 , BYVAL dwFlagsRemove AS DWORD
 , BYVAL pProgress AS IProgressNotify
 ) AS LONG
 ' =====================================================================================
 METHOD RegisterNotification ( ' VTable offset = 52
 BYVAL dwReserved AS DWORD
 , BYVAL hwnd AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD UnregisterNotification ( ' VTable offset = 56
 BYVAL dwReserved AS DWORD
 , BYVAL hwnd AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD CompactAll ( ' VTable offset = 60
 BYVAL dwReserved AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetFirstSubFolder ( ' VTable offset = 64
 BYVAL dwFolderId AS LONG
 , BYREF pProps AS FOLDERPROPS
 , BYREF phEnum AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetNextSubFolder ( ' VTable offset = 68
 BYVAL hEnum AS DWORD
 , BYREF pProps AS FOLDERPROPS
 ) AS LONG
 ' =====================================================================================
 METHOD GetSubFolderClose ( ' VTable offset = 72
 BYVAL hEnum AS DWORD
 ) AS LONG
 ' =====================================================================================
END INTERFACE
#ENDIF ' /* __IStoreNamespace_INTERFACE_DEFINED__ */
#IF NOT %DEF(%IStoreFolder_INTERFACE_DEFINED)
%EQUATE `IStoreFolder_INTERFACE_DEFINED = 1
%EQUATE `MSG_DELETED = &H0001 ' // The message has been deleted, compaction will remove it
%EQUATE `MSG_UNREAD = &H0002 ' // The message is marked as un-read
%EQUATE `MSG_SUBMITTED = &H0004 ' // For messages waiting to be sent: OUTBOX ONLY
%EQUATE `MSG_UNSENT = &H0008 ' // For msgs-in-progress saved to a folder
%EQUATE `MSG_RECEIVED = &H0010 ' // For messages that came from a server
%EQUATE `MSG_NEWSMSG = &H0020 ' // For news messages
%EQUATE `MSG_NOSECUI = &H0040 ' // For messages where the user wants to die
%EQUATE `MSG_VOICEMAIL = &H0080 ' // The message has the X-Voicemail header set...
%EQUATE `MSG_REPLIED = &H0100 ' // The message has been replied to
%EQUATE `MSG_FORWARDED = &H0200 ' // The message has been forwarded to
%EQUATE `MSG_RCPTSENT = &H0400 ' // S/MIME Receipt has been sent
%EQUATE `MSG_FLAGGED = &H0800 ' // The message is currently flags
%EQUATE `MSG_LAST = &H0200 ' // ** Keep this puppy updated!! **
%EQUATE `MSG_EXTERNAL_FLAGS = &H00FE
%EQUATE `MSG_FLAGS = &H000F
' // Size = 68 bytes
TYPE MESSAGEPROPS DWORD
 cbSize AS DWORD
 dwReserved AS DWORD
 dwMessageId AS DWORD ' // MESSAGEID
 dwLanguage AS DWORD
 dwState AS DWORD
 cbMessage AS DWORD
 priority AS LONG ' // IMSGPRIORITY enum
 ftReceived AS FILETIME
 ftSent AS FILETIME
 pszSubject AS ASCIIZ PTR ' // LPSTR
 pszDisplayTo AS ASCIIZ PTR ' // LPSTR
 pszDisplayFrom AS ASCIIZ PTR ' // LPSTR
 pszNormalSubject AS ASCIIZ PTR ' // LPSTR
 dwFlags AS DWORD
 pStmOffsetTable AS DWORD ' // IStream
END TYPE
'TYPE HBATCHLOCK
' unused AS DWORD
'END TYPE
'typedef struct HBATCHLOCK__ *HBATCHLOCK;
'typedef HBATCHLOCK *LPHBATCHLOCK;
%EQUATE `MSGPROPS_FAST = &H00000001 ' // See MESSAGEPROPS structure, improved performance
%EQUATE `COMMITSTREAM_REVERT = &H00000001 ' // Don't add this stream/message to the folder
' ########################################################################################
' Interface name = IStoreFolder
' IID = E70C92AC-4BFD-11d1-8A95-00C04FB951F3
' Inherited interface = IUnknown
' ########################################################################################
INTERFACE IStoreFolder $IID_IStoreFolder
 INHERIT IUnknown
 ' =====================================================================================
 METHOD GetFolderProps ( ' VTable offset = 12
 BYVAL dwReserved AS DWORD
 , BYREF pProps AS FOLDERPROPS
 ) AS LONG
 ' =====================================================================================
 METHOD FreeMessageProps ( ' VTable offset = 16
 BYREF pProps AS MESSAGEPROPS
 ) AS LONG
 ' =====================================================================================
 METHOD DeleteMessages ( ' VTable offset = 20
 BYREF pMsgIdList AS MESSAGEIDLIST
 , BYVAL dwReserved AS DWORD
 , BYVAL pProgress AS IProgressNotify
 ) AS LONG
 ' =====================================================================================
 METHOD SetLanguage ( ' VTable offset = 24
 BYVAL dwLanguage AS DWORD
 , BYVAL dwReserved AS DWORD
 , BYREF pMsgIdList AS MESSAGEIDLIST
 ) AS LONG
 ' =====================================================================================
 METHOD MarkMessagesAsRead ( ' VTable offset = 28
 BYVAL fRead AS LONG
 , BYVAL dwReserved AS DWORD
 , BYREF pMsgIdList AS MESSAGEIDLIST
 ) AS LONG
 ' =====================================================================================
 METHOD SetFlags ( ' VTable offset = 32
 BYREF pMsgIdList AS MESSAGEIDLIST
 , BYVAL dwState AS DWORD
 , BYVAL dwStatemask AS DWORD
 , BYREF prgdwNewFlags AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD OpenMessage ( ' VTable offset = 36
 BYVAL dwMessageId AS DWORD
 , BYREF riid AS GUID
 , BYREF ppvObject AS IUnknown
 ) AS LONG
 ' =====================================================================================
 METHOD SaveMessage ( ' VTable offset = 40
 BYREF riid AS GUID
 , BYVAL pvObject AS IUnknown
 , BYVAL dwMsgFlags AS DWORD
 , BYREF pdwMessageId AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD BatchLock ( ' VTable offset = 44
 BYVAL dwReserved AS DWORD
 , BYREF phBatchLock AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD BatchFlush ( ' VTable offset = 48
 BYVAL dwReserved AS DWORD
 , BYVAL hBatchLock AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD BatchUnlock ( ' VTable offset = 52
 BYVAL dwReserved AS DWORD
 , BYVAL hBatchLock AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD CreateStream ( ' VTable offset = 56
 BYVAL hBatchLock AS DWORD
 , BYVAL dwReserved AS DWORD
 , BYREF ppStream AS IStream
 , BYREF pdwMessageId AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD CommitStream ( ' VTable offset = 60
 BYVAL hBatchLock AS DWORD
 , BYVAL dwReserved AS DWORD
 , BYVAL dwMsgFlags AS DWORD
 , BYVAL pStream AS IStream
 , BYVAL dwMessageId AS DWORD
 , BYVAL pMessage AS IMimeMessage
 ) AS LONG
 ' =====================================================================================
 METHOD RegisterNotification ( ' VTable offset = 64
 BYVAL dwReserved AS DWORD
 , BYVAL hwnd AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD UnregisterNotification ( ' VTable offset = 68
 BYVAL dwReserved AS DWORD
 , BYVAL hwnd AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD Compact ( ' VTable offset = 72
 BYVAL dwReserved AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetFirstMessage ( ' VTable offset = 76
 BYVAL dwFlags AS DWORD
 , BYVAL dwMsgFlags AS DWORD
 , BYVAL dwMsgIdFirst AS DWORD
 , BYREF pProps AS MESSAGEPROPS
 , BYREF phEnum AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetNextMessage ( ' VTable offset = 80
 BYVAL hEnum AS DWORD
 , BYVAL dwFlags AS DWORD
 , BYREF pProps AS MESSAGEPROPS
 ) AS LONG
 ' =====================================================================================
 METHOD GetMessageClose ( ' VTable offset = 84
 BYVAL hEnum AS DWORD
 ) AS LONG
 ' =====================================================================================
END INTERFACE
#ENDIF ' /* __IStoreFolder_INTERFACE_DEFINED__ */
'//+-------------------------------------------------------------------------
'// Prototypes
'//--------------------------------------------------------------------------
DECLARE FUNCTION CoStartOutlookExpress LIB "msoe.dll" ALIAS "CoStartOutlookExpress" ( BYVAL dwFlags AS QUAD , BYREF pszCmdLine AS ASCIIZ , BYVAL nCmdShow AS LONG ) AS LONG
DECLARE FUNCTION CoCreateOutlookExpress LIB "msoe.dll" ALIAS "CoCreateOutlookExpress" ( BYVAL pUnkOuter AS IUnknown
 , BYREF ppUnknown AS IUnknown
 ) AS LONG
' ========================================================================================
' Gets the content of the message
' ========================================================================================
FUNCTION IStoreFolder_GetMessageContent (BYVAL pStoreFolder AS IStoreFolder, BYVAL dwMessageId AS DWORD, BYREF strContent AS STRING) AS LONG
 LOCAL hr AS LONG
 LOCAL pIStream AS IStream
 LOCAL IID_IStream AS GUID
 LOCAL plibNewPosition AS QUAD
 LOCAL pcbRead AS DWORD
 LOCAL tstatstg AS STATSTG
 LOCAL numchars AS LONG
 LOCAL strText AS STRING
 IF ISNOTHING(pStoreFolder) THEN FUNCTION = %E_POINTER : EXIT FUNCTION
 IF VARPTR(strContent) = 0 THEN FUNCTION = %E_INVALIDARG : EXIT FUNCTION
 ' Open the message in a stream
 IID_IStream = $IID_IStream
 hr = pStoreFolder.OpenMessage(dwMessageId, IID_IStream, pIStream)
 IF hr = %S_OK THEN
 hr = pIStream.Seek(0, %STREAM_SEEK_SET, plibNewPosition)
 IF hr = %S_OK THEN
 hr = pIStream.Stat(tstatstg, %STATFLAG_NONAME)
 IF hr = %S_OK THEN
 IF tstatstg.cbsize => 0 THEN
 numchars = tstatstg.cbsize
 strText = SPACE$(numchars)
 hr = pIStream.Read(STRPTR(strText), LEN(strText), pcbRead)
 IF hr = %S_OK THEN
 IF pcbRead < numchars THEN strText = LEFT$(strText, pcbRead)
 strContent = strText
 END IF
 END IF
 END IF
 END IF
 ' Release the IStream interface
 pIStream = NOTHING
 END IF
 FUNCTION = hr
END FUNCTION
' ========================================================================================
#ENDIF
