Hi
I tried checking attachments of oMessage in OnSMTPData event for both send and receive messages. Always the 'oMessage.Attachments.Count' is observed as 0. We have hMailServer version 5.6.7 installed.
Sample script :
If Not message.Attachments Is Nothing Then
If message.Attachments.Count > 0 Then
EntryToLog("Attachments count " + Cstr(message.Attachments.Count))
nTotAttSize = 0
For i = 1 to message.Attachments.Count ' attachment
oAtt = message.Attachments.Item(i-1)
EntryToLog("att Size " + Cstr(message.Attachments.Item(i-1).Size))
nTotAttSize = nTotAttSize + oAtt.Size
Next 'i - attachment
EntryToLog("nTotAttSize " + Cstr(nTotAttSize))
End If
End If
Am I missing something fundamental ?
oMessage.Attachments.Count is always 0
- jimimaseye
- Moderator
- Posts: 8917
- Joined: 2011-09-08 17:48
Re: oMessage.Attachments.Count is always 0
As designed. The data isn't there at that time. See https://www.hmailserver.com/documentati ... onSMTPdata
The attachments will be there at OnAcceptMessage. Try that.
[Entered by mobile. Excuse my spelling.]
The attachments will be there at OnAcceptMessage. Try that.
[Entered by mobile. Excuse my spelling.]
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829
Re: oMessage.Attachments.Count is always 0
Did check in 4 event .. OnSMTPData, OnAcceptMessage, OnDeliveryStart and OnDeliverMessage . In all events attachment count is coming 0.
OnSMTPData Attachment Count 0
OnAcceptMessage Attachment Count 0
OnDeliveryStart Attachment Count 0
OnDeliverMessage Attachment Count 0
OnSMTPData Attachment Count 0
OnAcceptMessage Attachment Count 0
OnDeliveryStart Attachment Count 0
OnDeliverMessage Attachment Count 0
- jimimaseye
- Moderator
- Posts: 8917
- Joined: 2011-09-08 17:48
Re: oMessage.Attachments.Count is always 0
Something wrong with your script then.
Post it and let us look at it (including the SUB placement as it appears in the handlers script).
Post it and let us look at it (including the SUB placement as it appears in the handlers script).
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829
Re: oMessage.Attachments.Count is always 0
Script is very simple
Code: Select all
Sub OnSMTPData(oClient, oMessage)
EntryToLog("OnSMTPData Attachment Count " + CStr(oMessage.Attachments.Count))
End Sub
Sub OnAcceptMessage(oClient, oMessage)
EntryToLog("OnAcceptMessage Attachment Count " + CStr(oMessage.Attachments.Count))
End Sub
Sub OnDeliveryStart(oMessage)
EntryToLog("OnDeliveryStart Attachment Count " + CStr(oMessage.Attachments.Count))
End Sub
Sub OnDeliverMessage(oMessage)
EntryToLog("OnDeliverMessage Attachment Count " + CStr(oMessage.Attachments.Count))
End Sub
Function EntryToLog (pLogMsg)
If sLogFile <> "" Then
Dim svbs, f, i
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
pLogMsg = CStr(Now) + " " + pLogMsg
svbs = Split(pLogMsg, vbCrLf)
Set f = fso.opentextfile(sLogFile, 8, True)
For i = 0 To UBound(svbs)
f.writeline(svbs(i))
Next
f.Close
End If
End Function
- jimimaseye
- Moderator
- Posts: 8917
- Joined: 2011-09-08 17:48
Re: oMessage.Attachments.Count is always 0
This should write the same detail to the standard Events log. How does it compare?
Code: Select all
Sub OnSMTPData(oClient, oMessage)
EventLog.Write("OnSMTPData Attachment Count " & oMessage.Attachments.Count )
End Sub
Sub OnAcceptMessage(oClient, oMessage)
EventLog.Write("OnAcceptMessage Attachment Count " & oMessage.Attachments.Count )
End Sub
Sub OnDeliveryStart(oMessage)
EventLog.Write("OnDeliveryStart Attachment Count " & oMessage.Attachments.Count )
End Sub
Sub OnDeliverMessage(oMessage)
EventLog.Write("OnDeliverMessage Attachment Count " & oMessage.Attachments.Count )
End Sub
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829
Re: oMessage.Attachments.Count is always 0
The values are same in eventlog.write / custom log (what mentioned in script)
I observed now the count is reflected as you mentioned from 'OnAcceptMessage' event.
But for sent email, the count is not coming in any event.
I observed now the count is reflected as you mentioned from 'OnAcceptMessage' event.
But for sent email, the count is not coming in any event.