WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

MAPI

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

MAPILogonEx vs. MAPILogon

Keywords:   MAPILogonEx MAPILogon

Question:

I would like to use amke a DllCall to the MAPI APIs; MAPILogonEx and MAPI32.dll instead of using the Mapi Extender function mLogon, which uses MapiLogon API.

I have looked at the DLLCall MAPI examples in the tech support area and found them to be helpful, but am still having trouble.

Specifically, I am having a hard time understanding the references to "Bitmask of flags" found in the MapilogonEx documentation on the MSDN cd.

Has anyone had any experience with this?

Is there a better source of information that I should be looking for?

Please let me know.

Answer:

Well there are a bunch of "flags" that can be set to modify exactly how the logon occurs.

Using 0 works a lot of the time.

Otherwise you have to decide what flags you want set. Then you have to look up the numerical values for each of the flags you want and then add them all together and pass the sum of the desired flags as the "flag" value in MapiLogonEX.

PS. MapiLogonEx only seems to work with the Microsoft MAPI client. It does not work with the Netscape version.

Question (cont'd):

If I manage to get this working, I will have a message sender to share that can run as a service on NT.

Another benefit besides running as a service will be that this sender can push the messages directly into the exchange message store. (Bypassing the IMC alltogether)

Most other methods for doing this (text file to mail message conversion) require the use of SMTP. When you are only pushing messages into exchange, this creates unnecessary traffic and additional points of failure.

I have made some progress, and wanted to share what I have found so far.

The hardest part was finding the values for the various flags.

There are still two I need to find: MAPI_UNICODE, and MAPI_USE_DEFAULT

Also, I am not quite sure how to implement the MAPIINIT_0 structure.

Any advice in those areas would be helpful.


dllhandle=DllLoad("C:\winnt\system32\MAPI32.DLL")

hwnd=dllhwnd("")
bbhandle=BinaryAlloc(4)
BinaryEODSet(bbhandle,4)
        
;; Need to figure out the MAPIINIT_0 stuff here

tmp_init=DLLCALL(dllhandle,long:"MAPIInitialize",lpnull)
;message("mapiinitialize returned",">%tmp_init%<")

MAPI_LOGON_UI = 1               ; original hex value 0x00000001  ; Display logon UI
MAPI_NEW_SESSION = 2            ; original hex value 0x00000002  ; Don't use shared session
MAPI_ALLOW_OTHERS = 8           ; original hex value 0x00000008  ; Make this a shared session
MAPI_EXPLICIT_PROFILE = 16      ; original hex value 0x00000010  ; Don't use default profile
MAPI_EXTENDED = 32              ; original hex value 0x00000020  ; Extended MAPI Logon
MAPI_FORCE_DOWNLOAD = 4096      ; original hex value 0x00001000  ; Get new mail before return
MAPI_SERVICE_UI_ALWAYS = 8192   ; original hex value 0x00002000  ; Do logon UI in all providers
MAPI_NO_MAIL = 32768            ; original hex value 0x00008000  ; Do not activate transports
MAPI_PASSWORD_UI = 131072       ; original hex value 0x00020000  ; Display password UI only
MAPI_TIMEOUT_SHORT = 1048576    ; original hex value 0x00100000  ; Minimal wait for logon resources
;; MAPI_UNICODE = "Need to find this value"             ;
;; MAPI_USE_DEFAULT = "Need to find this value"         ;

profile = "profile name goes here"

;tmp_logonEX=DLLCALL(dllhandle,long:"MAPILogonEx",long:hwnd,lpstr:"",lpstr:"",long:4096,lpbinary:bbhandle)
tmp_logonEX=DLLCALL(dllhandle,long:"MAPILogonEx",long:hwnd,lpstr:profile,lpstr:"",long:MAPI_NEW_SESSION|MAPI_EXTENDED|MAPI_NO_MAIL,lpbinary:bbhandle)
;message("mapiLogonex returned",">%tmp_logonEX%<")

sessionid=BinaryPeek4(bbhandle,0)

if tmp_logonEX !=0 
        message("mapiLogon failed","Error Code: %tmp_logonEX%")
        exit
endif

tmp_uninit=DLLCALL(dllhandle,long:"MAPIUninitialize")
message("mapiUNinitialize returned",">%tmp_uninit%<")

DLLfree(dllhandle)

exit


Answer:

MAPI_UNICODE:
original hex value 0x80000000
MAPI_USE_DEFAULT:
original hex value 0x00000040
Here is another MAPI Structure
;********MAPIRECIPDESC structure (where LPOriginater points)
BinaryPoke4(bb,800,0);field ULReserved

BinaryPoke4(bb,804,0);field ULRecipclas

BinaryPoke4(bb,808,bbaddr+Stringspace);field lpszname
BinaryPokeStr(bb,stringspace,senddisplayname)

stringspace=(stringspace+strlen(senddisplayname)+ 10)  &  4294967292

BinaryPoke4(bb,812,bbaddr+stringspace);
BinaryPokeStr(bb,stringspace,sender)
stringspace=(stringspace+strlen(sender)+ 10)  &  4294967292

BinaryPoke4(bb,816,0); ulEIDsize


BinaryPoke4(bb,820,0); LpEntryID

Article ID:   W12531
Filename:   MAPILogonEx vs. MAPILogon.txt
File Created: 2017:07:28:13:58:31
Last Updated: 2001:01:09:12:38:42