Is there an existing instantiation of the Application object, that is already authenticated, exposed within the event handlers and rule-triggered scripts? What is it's name?
Reason: My rule-triggered script need to access the parent Account for the oMessage message parameter, and access the parent Domain for the Account.
Code examples of same appreciated.
Instantiation of Application object
Re: Instantiation of Application object
To ensure that I meet the Australian laws about logging specific detail, I write custom per-domain logs
Code: Select all
Function DomainLogging(oMessage)
'custom event
'uses functions: CustomMonthlyLog
'uses globals: g_sAdminPassword
'called from: Rules
Dim i, j, oDomain, temptext, oApp, Local, tempDomain
Set oApp = CreateObject("hMailServer.Application")
' Give this script permission to access all
' hMailServer settings.
Call oApp.Authenticate("Administrator", g_sAdminPassword)
tempDomain = Right(oMessage.FromAddress, Len(oMessage.FromAddress) - InStr(oMessage.FromAddress,"@"))
Local = 0
For i = 1 to oApp.domains.count
if (InStr(1, tempDomain, oApp.Domains.item(i-1).name, 1) > 0) Then ' Local sender
local = local + 1
oDomain = tempDomain
End If
For j = 1 to oApp.Domains.item(i-1).DomainAliases.count
if (InStr(1, tempDomain, oApp.Domains.item(i-1).DomainAliases.item(j-1).AliasName, 1) > 0) Then ' Local user.
local = local + 1
oDomain = oApp.Domains.Item(i-1).Name
End If
Next 'j
Next 'i
If Local > 0 Then
CustomMonthlyLog "", oDomain
CustomMonthlyLog " New email from " & oMessage.FromAddress, oDomain
CustomMonthlyLog " Subject is:-" & oMessage.Subject, oDomain
CustomMonthlyLog " Number of recipients is " & oMessage.Recipients.Count & _
" Number of Attachments is " & oMessage.Attachments.Count, oDomain
For i = 1 To oMessage.Recipients.Count
temptext = " Recipient number " & i & " is " & oMessage.Recipients.Item(i-1).Address
CustomMonthlyLog temptext, oDomain
Next
For i = 1 To oMessage.Attachments.Count
temptext = " Attachment number " & i & " is " & oMessage.Attachments.Item(i-1).filename
Call CustomMonthlyLog( temptext, oDomain)
Next
CustomMonthlyLog " Message size is:-" & oMessage.Size, oDomain
End If
End Function
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation
https://www.hmailserver.com/documentation