Are you a world traveler? ZoneTick is a cool utility that'll help you stay in touch over multiple time zones!
 
Working with Inbound Messages for Sample Gateway  
Nik Okuntseff  MS Exchange Server Programming 

Working with Inbound Messages for Sample Gateway

Sample gateway appears to be fully functional gateway. As I have shown previously it can be configured to process messages of different types. However, when I was describing and testing functionality of the gateway I only referred to "sending" messages through it. When I needed to check whether gateway works or not I was sending a message to it and observed it to appear in its Out folder. We need to test whether messages can be sent backwards as well. If we can do that, perhaps we could utilize this sample gateway in a great deal. Let us see how messages can be received via sample gateway.

The following very simple procedure will demonstrate how message can be transferred backward through sample gateway. I assume that we have EDK gateway installed (this is sample gateway in its default pure form, without any modifications like changing its message type). Send an EDK message via sample gateway and observe it to appear in its Out folder. Open this message with notepad. Normally, in the beginning of this message you would see something like this:

X-Tnef-Attach:
MAIL FROM:NikO@DEV.Rydex Industries Corporation.com
RCPT TO:EDK_e-mail_address
DATA:
X-Message-Class:IPM.NOTE

The second line above indicates the sender in Microsoft Exchange environment and the third line - the recipient.  You need to edit the third line to make the recipient yourself. You can do it by copying data from the second line and putting it on the third, like here below:

X-Tnef-Attach:
MAIL FROM:NikO@DEV.Rydex Industries Corporation.com
RCPT TO:NikO@DEV.Rydex Industries Corporation.com
DATA:
X-Message-Class:IPM.NOTE

Of course, in your particular case the addressing information will be different.
Now drop this edited file into the gateway's In folder and observe it to be delivered to your Exchange or Outlook client.

The procedure described above will only work for messages without rich text information. If you have created such a recipient using the "Other Address" template you should clear "Always send to this recipient in Microsoft Exchange rich-text format" check-box. If you forget to do this the message will be accompanied by a TNEF attachment with rich text info which apparently has addressing information as well. Then modifying RCPT TO property and not modifying accompanying TNEF attachment obviously puts these two parts out of synchronization and your gateway will be unable to process incoming messages. In fact, the gateway will attempt to process such message but will fail to convert it from RFC 822 standard to MAPI. I assume that it is configured to use ipm_in.dll conversion dll - the one which is installed by default. You would see an event in the application event log saying "ipm_in.dll conversion DLL convert function failed: point = SAMPLEGW.INBOUND, class = ENVELOPE.IPM, error code = 80004005". This error code is generic error: E_FAIL. Unfortunately, that's all that the event says - generic error of some kind.

When errors like this happen it is possible and in fact very useful to run gateway under debugger and see where the call really fails. I have traced this error to the actual call into ipm_in.dll (m_pDllVector->pfnCnvConvert). I wanted to investigate it further and find out what was really going on. Fortunately, Microsoft provided source code for this conversion dll - it may be found in Mssdk/Samples/Exchange/ipm_in folder. I have managed to compile it and run under debugger by using my modified gateway as an executable for debug session with NOTSERV <GUID> parameters and specifying correct working directory. Having done that I have determined that inside ipm_in.dll the code failed to open TNEF attachment (IMessage::OpenAttach) when processing incoming message. I believe the reason of this being inconsistency in addressing (one address in RCPT TO property and the other in TNEF attachment). Fortunately everything works fine for messages without rich text info.

One other useful thing to know is that a lot of Exchange related code (and ipm_in.dll is one example) uses Exchange libraries such as exchsdk.lib. In order to step in its functions you need to have source code. Conveniently it is a part of Platform SDK installation. You will need to tell the debugger where to find it.
 

[ Contents | Home ]

Send comments and suggestions to niko@wrconsulting.com
Copyright © 1997-1998 by Nik Okuntseff