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


SUMMARY

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

DETAIL

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
Wend
Close (hFile)
if PerformAction = True Then
Kill(MsgCommandFile)
Kill(MsgFile)
Exit Sub

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

MORE INFORMATION

How to run multiple processes in a MTA Pickup Event: https://www.mailenable.com/kb/viewarticle.asp?&File=me020204.htm 



Product:MailEnable (All Versions)
Article:ME020028
Module:MTA
Keywords:pickup,event,vb,code,visual,basic,example,mta,mail,transfer,agent,pick-up,pick,up,MTA
Class:INF: Product Information
Created:8/05/2002 8:32:00 PM
Revised:Monday, January 24, 2022
Author:
Publisher:MailEnable