MTA Pickup Event (Example VB Code for MTA Pickup Event)


How pickup events operate when integrated with the MailEnable Mail Transfer Agent (MTA).


When the MTA moves a message between connectors, an optional executable file can be run. This is called a pickup event. The MTA pickup event will pass the mail message filename to the external application. For example, a VB script that adds some text to the end of each email could be activated through the pickup event. The application/script receives the messagefilename and connectortype as parameters.

e.g. program messagefilename connectortype

Where program is the program filename, messagefilename is the name of the message file and connectortype is the type of messages (i.e. SMTP, LS, SF).

Be aware that the directory path to the message is not passed to the program. The directory path will need to be read from the Windows registry in the pickup event application.

Firstly, access the registry and determine the location of the connectors queue and construct the location of the message command file and the message itself.

Simple Visual Basic Example:

Sub Main()
' This routine is unsupported and is provide for reference purposes only
' This primitive example checks MTA messages for .exe in the message
' contents and deletes any files that do!
Dim sMsgCommandFile as String
Dim sMsgFile as String
Dim hFile As Long
Dim args() As String
Dim sFileLine as String

args() = Split(Command(), " ")
sMsgCommandFile = GetRegistryString("SOFTWARE\Mail Enable\Mail Enable\Connectors", "Connector Root Directory") & _
"\" & args(1) & "\Inbound\" & args(0)
sMsgFile = GetRegistryString("SOFTWARE\Mail Enable\Mail Enable\Connectors", "Connector Root Directory") & _
"\" & args(1) & "\Inbound\Messages\" & args(0)
hFile = FreeFile
bPerformAction = False
On Error goto Err Handler
Open sMsgFile For Input as #hFile
While Not EOF(hFile)
Line Input #hFile, sFileLine
if Instr(1,lCase(sFileLine),".exe") Then
 bPerformAction = True
Exit While
end if
Close (hFile)
if PerformAction = True Then
Exit Sub

App.LogEvent "Could not process pickup event for Connector: " & ConnectorCode & _
" Message ID: " & MessageID
End Sub
  • Print
  • Copy Code


How to run multiple processes in a MTA Pickup Event: 

Product:MailEnable (All Versions)
Class:INF: Product Information
Created:8/05/2002 8:32:00 PM
Revised:Monday, January 24, 2022