Sub OnDeliverMessage(oMessage)
Dim LocalOnlyAccounts(100)
Dim temprecipients(100)
Dim i, j, k, l
Dim varDomain
Dim varAddress
varDomain = "mydomain.com"
LocalOnlyAccounts(0)= "user1" & "@" & varDomain
LocalOnlyAccounts(1)= "user2" & "@" & varDomain
For i = 0 to uBound(LocalOnlyAccounts)
If oMessage.FromAddress = LocalOnlyAccounts(i) then 'sender is restricted account
for j = 0 to oMessage.recipients.count -1
temprecipients(j) = oMessage.recipients.item(j).address
next 'j
j = 0
k = oMessage.recipients.count -1
while j <= k
If oMessage.recipients.item(j).islocaluser = false then 'remove non-local recipients
l= j
while l < k
temprecipients(l) = temprecipients(l+1)
l=l+1
wend
temprecipients(k) = ""
k=k-1
else
j=j+1
end if
wend
oMessage.clearrecipients()
For j = 0 to k
varAddress = temprecipients(j)
oMessage.AddRecipient "", varAddress
Next 'j
oMessage.save
End if
Next 'i
End Sub