Good work, ToutEnMasm
Btw, i just suceeded to initialize that crappy mapi stuff. Now will ty to acess the Com data in order to convert the rtftohtml
here is the code i made:
;;
References:
http://www.outlookcode.com/archive0/d/mapi.htm
http://msdn.microsoft.com/en-us/library/office/cc963763%28v=office.12%29.aspx
http://msdn.microsoft.com/en-us/library/office/dd181963%28v=office.12%29.aspx
http://msdn.microsoft.com/en-us/library/office/cc815369%28v=office.12%29.aspx
http://www.wischik.com/lu/programmer/mapi_utils.html
http://www.clydesdalesoftware.com/Blog/05-05-15/Building_Outlook_Add-ins_with_ATL_C.aspx
https://www.google.com.br/search?q=rtf%20encapsulated&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a&channel=np&source=hp
http://msdn.microsoft.com/en-us/library/ee159984%28v=exchg.80%29.aspx
http://msdn.microsoft.com/en-us/library/ee158614%28v=exchg.80%29.aspx
http://msdn.microsoft.com/en-us/library/ee217484%28v=exchg.80%29.aspx
http://social.msdn.microsoft.com/Forums/en-US/outlookdev/thread/bd852fb5-159d-4250-aaa5-3e2a32be0fcb
http://msdn.microsoft.com/en-us/library/office/dd162409%28v=office.12%29.aspx
;;
[szMAPIDLL: B$ 0 #&MAX_PATH]
[pfnMAPIInitialize: D$ 0]
[pfnMAPIUninitialize: D$ 0]
[Sz_MapiError1: B$ "The application could not access an Exchange Server 2010 server.
Try installing the hotfix 2685289 for it as described in:
http://support.microsoft.com/kb/2674185
http://support.microsoft.com/kb/2685289
http://support.microsoft.com/kb/892231/pt-br
If it also fails, it means that you don´t have uou probably don´t have
'Microsoft Exchange Server MAPI Client and Collaboration Data Objects 1.2.1'
installed on your machine, as describe in:
http://support.backup-connect.com/2010/01/21/insufficient-permissions-for-mailbox-backup
Error= Mapi_E_call_failed Detail= Unspecified error:
How to solve error: Error= Mapi_E_call_failed Detail= Unspecified error:
When configurating or performing a maillevel backup on a server 2003/2008, the following error can occur:
logonSession 'ERROR= MAPI_E_CALL_FAILED Detail= Unspecified error'
This problem is caused by the MAPI Files that are stored on the system. This is often caused by a previous used backup software.
* To resolve the issue, please verify if the Mapisp32.exe file does exist on the system (C:\WINDOWS\system32\mapisp32.exe).
In some cases, the Mapisp32.exe file may have been removed or renamed by anti-virus software.
You can restore this by reinstalling the Microsoft Exchange Server MAPI Client and Collaboration Data Objects 1.2.1 (ExchangeMAPICdo.exe).
Make sure you uninstall the old version first. Then run Mapisp32.exe.
* Disable old back-up software (i.e. backup exec), and make sure outlook, outlook express or windows mail are not installed on the server.
____________________________________________________________
To install, download it at:
http://www.microsoft.com/en-us/download/confirmation.aspx?id=1004
or
http://download.microsoft.com/download/A/2/4/A24BD8F5-4475-4C3B-B051-7A264B660E90/ExchangeMapiCdo.EXE", 0]
Proc MapiWorks:
Local @hMapiDLL
call InitializeMapiFunctions szMAPIDLL, pfnMAPIInitialize, pfnMAPIUninitialize
On eax = 0, ExitP
mov D@hMapiDLL eax
; Initialize the MAPI subsystem
call D$pfnMAPIInitialize &NULL
; &MAPI_E_INVALID_PARAMETER &MAPI_E_UNKNOWN_FLAGS &MAPI_E_NOT_ENOUGH_RESOURCES &MAPI_E_CALL_FAILED <---- DAMN IT ! &MAPI_E_NOT_INITIALIZED
; &MAPI_E_CALL_FAILED = need to install an update http://support.microsoft.com/kb/2674185 http://support.microsoft.com/hotfix/KBHotfix.aspx?kbnum=892231&kbln=pt-br
; http://support.backup-connect.com/2010/01/21/insufficient-permissions-for-mailbox-backup/
; http://www.microsoft.com/en-us/download/confirmation.aspx?id=1004
..If eax <> &S_OK
.If eax = &MAPI_E_CALL_FAILED
call 'USER32.MessageBoxA' 0, Sz_MapiError1, {'Error: Mapi Failed (MAPI_E_CALL_FAILED)', 0}, &MB_OK__&MB_ICONWARNING__&MB_SYSTEMMODAL
.End_If
call 'KERNEL32.FreeLibrary' D@hMapiDLL
xor eax eax
ExitP ; something wrong at initilization
..End_If
; Here’s where you make calls to other MAPI APIs
; Uninitialize the MAPI subsystem
call D$pfnMAPIUninitialize
call 'KERNEL32.FreeLibrary' D@hMapiDLL
EndP
[s_szMSIApplicationLCID: B$ "Microsoft\\Office\\9.0\\Outlook\0LastUILanguage\0", 0]
[s_szMSIOfficeLCID: B$ "Microsoft\\Office\\9.0\\Common\\LanguageResources\0UILanguage\0InstallLanguage\0", 0]
[s_szMSIOfficeLCID2: B$ "Microsoft\Office\12.0\Common\LanguageResources\0InstalledUIs\0", 0]
Proc InitializeMapiFunctions:
Arguments @szMAPIDir, @pMapiInit, @pMapiDeInit
Local @hinstStub, @pfnFGetComponentPath
Uses edi, ecx, ebx, edx, esi
mov D@hinstStub 0
mov D@pfnFGetComponentPath 0
call 'KERNEL32.LoadLibraryA' {B$ "mapistub.dll", 0}
If eax = 0
call 'KERNEL32.LoadLibraryA' {B$ "mapi32.dll", 0} | On eax = 0, ExitP
End_If
mov D@hinstStub eax
call 'KERNEL32.GetProcAddress' eax, {B$ "FGetComponentPath", 0} | mov D@pfnFGetComponentPath eax
...If eax <> 0
mov edi D@szMAPIDir
call D@pfnFGetComponentPath {B$ "FF1D0740-D227-11D1-A4B0-006008AF820E", 0}, s_szMSIApplicationLCID, edi, &MAX_PATH, &TRUE | on eax <> 0, jmp L1>
call D@pfnFGetComponentPath {B$ "FF1D0740-D227-11D1-A4B0-006008AF820E", 0}, s_szMSIOfficeLCID, edi, &MAX_PATH, &TRUE | on eax <> 0, jmp L1>
call D@pfnFGetComponentPath {B$ "FF1D0740-D227-11D1-A4B0-006008AF820E", 0}, s_szMSIOfficeLCID2, edi, &MAX_PATH, &TRUE | on eax <> 0, jmp L1>
call D@pfnFGetComponentPath {B$ "473FF9A0-D659-11D1-A4B2-006008AF820E", 0}, &NULL, edi, &MAX_PATH, &TRUE
If eax = 0
call 'KERNEL32.FreeLibrary' D@hinstStub | xor eax eax | ExitP
End_If
L1:
If B$edi = '\'
mov B$edi 0
inc edi
End_If
...End_If
call 'KERNEL32.GetProcAddress' D@hinstStub, {B$ "MAPIInitialize", 0}
If eax <> 0
mov esi D@pMapiInit
mov D$esi eax
End_If
call 'KERNEL32.GetProcAddress' D@hinstStub, {B$ "MAPIUninitialize", 0}
If eax <> 0
mov esi D@pMapiDeInit
mov D$esi eax
End_If
mov eax D@hinstStub
EndP
If the error shows up,follows the instructions and install the last hotfixor the "Microsoft Exchange Server MAPI Client and Collaboration Data Objects 1.2.1" at:
http://www.microsoft.com/downloads/details.aspx?FamilyID=E17E7F31-079A-43A9-BFF2-0A110307611E&displaylang=enI was having that crappy error and had no idea,untill i found the solution and install this thing
Of course, all the above code can be simply replaced by a call to the initialize function as:
call 'mapi32.MAPIInitialize' &NULLBut,since i was following M$ instructions, it lead me to that code

At least now i know why i was not being able to initialize the Mapi library.
Now is a matter of see the relationship between mapi32.dll and cdosys.dll, in order to achieve the proper convertion functions.