Page 1 of 1

Bug in attachment handling?

Posted: 2019-07-06 15:46
by SorenR
I have been working on script functionality to allow blocked attachments to be forwarded to a provided mail account.

It works in that it (the script) detects the attachments that hMailServer blocks and forward a cloned copy of the mail with the blocked attachments to for example "postmaster@mydomain.tld".

There is a but...

I'm using the following list af files to test with...

CDO-send.vbs
emailtest.asp
emailtest.htm
emailtest.html
emailtest.log
emailtest.ps1
emailtest.vbs
hmailserver_2019-06-20.log
wireshark.out
wireshark.pcap

.vbs and .ps1 are listed in the hMailServer attachment blocklist, none of the other extensions are listed.

And, yes, I had to work on Outlook registry values to dis-ban some of the extensions.

The normal email is received with the following attachments...

emailtest.asp
emailtest.htm
emailtest.log
emailtest.ps1.txt
emailtest.vbs.txt
hmailserver_2019-06-20.log
wireshark.out
wireshark.pcap

CDO-send.vbs and emailtest.html are GONE!
emailtest.ps1.txt and emailtest.vbs.txt are correctly blocked by hMailServer.

The second mail that should contain the blocked attachments is received by postmaster...

CDO-send.vbs
emailtest.htm
emailtest.html
emailtest.ps1
emailtest.vbs
emailtest.ps1.txt

emailtest.htm and emailtest.html are both included but neither should be there.
emailtest.ps1.txt should not be there.


The functionality of the script is as follows:

OnDeliveryStart(oMessage)
- Create unique folder based on email filename
- Save all attachments in folder
End

OnDeliverMessage(oMessage)
- if NOT headervalue (in cloned message)
- - List attachments and delete file by file (assuming remaining files are blocked extensions)
- - Blocked ext become .txt so cannot be deleted -> clone mail + add headervalue
- - Exit
- oMessage.Attachments.Clear
- Lookup remaining files in folder
- attach files
- send
- delete folder
End

Somehow files vanish and re-appear out of nowhere and I have a hard time explaining it.

Script is here...
https://www.hmailserver.com/forum/viewt ... 68#p213168

I also noticed weird behavior of attachments in this thread...
https://www.hmailserver.com/forum/viewt ... 96#p208596

Re: Bug in attachment handling?

Posted: 2019-07-07 02:30
by SorenR
Updated script https://www.hmailserver.com/forum/viewt ... 76#p213176

Log/trace

Code: Select all

2676		"2019-07-07 02:19:07.992"	"Sub OnDeliveryStart(oMessage)"
2676		"2019-07-07 02:19:07.992"	"(1'st run) strBaseName = {32CE5E4F-E949-4D21-854F-CB38BB0E291D}"
2676		"2019-07-07 02:19:07.992"	"(1'st run) strFolder = C:\hMailServer\Attachments\32\{32CE5E4F-E949-4D21-854F-CB38BB0E291D}"
2676		"2019-07-07 02:19:07.992"	"(1'st run) save attachment as C:\hMailServer\Attachments\32\{32CE5E4F-E949-4D21-854F-CB38BB0E291D}\CDO-send.vbs"
2676		"2019-07-07 02:19:08.008"	"(1'st run) save attachment as C:\hMailServer\Attachments\32\{32CE5E4F-E949-4D21-854F-CB38BB0E291D}\emailtest.asp"
2676		"2019-07-07 02:19:08.008"	"(1'st run) save attachment as C:\hMailServer\Attachments\32\{32CE5E4F-E949-4D21-854F-CB38BB0E291D}\emailtest.htm"
2676		"2019-07-07 02:19:08.008"	"(1'st run) save attachment as C:\hMailServer\Attachments\32\{32CE5E4F-E949-4D21-854F-CB38BB0E291D}\emailtest.html"
2676		"2019-07-07 02:19:08.008"	"(1'st run) save attachment as C:\hMailServer\Attachments\32\{32CE5E4F-E949-4D21-854F-CB38BB0E291D}\emailtest.log"
2676		"2019-07-07 02:19:08.023"	"(1'st run) save attachment as C:\hMailServer\Attachments\32\{32CE5E4F-E949-4D21-854F-CB38BB0E291D}\emailtest.ps1"
2676		"2019-07-07 02:19:08.023"	"(1'st run) save attachment as C:\hMailServer\Attachments\32\{32CE5E4F-E949-4D21-854F-CB38BB0E291D}\emailtest.vbs"
2676		"2019-07-07 02:19:08.023"	"(1'st run) save attachment as C:\hMailServer\Attachments\32\{32CE5E4F-E949-4D21-854F-CB38BB0E291D}\hmailserver_2019-06-20.log"
2676		"2019-07-07 02:19:08.039"	"(1'st run) save attachment as C:\hMailServer\Attachments\32\{32CE5E4F-E949-4D21-854F-CB38BB0E291D}\wireshark.out"
2676		"2019-07-07 02:19:08.070"	"(1'st run) save attachment as C:\hMailServer\Attachments\32\{32CE5E4F-E949-4D21-854F-CB38BB0E291D}\wireshark.pcap"
2676		"2019-07-07 02:19:08.273"	"Sub OnDeliverMessage(oMessage)"
2676		"2019-07-07 02:19:08.273"	"(1'st run) strFolder = C:\hMailServer\Attachments\32\{32CE5E4F-E949-4D21-854F-CB38BB0E291D}"
2676		"2019-07-07 02:19:08.273"	"(1'st run) delete file C:\hMailServer\Attachments\32\{32CE5E4F-E949-4D21-854F-CB38BB0E291D}\emailtest.ps1.txt FAILED!"
2676		"2019-07-07 02:19:08.273"	"(1'st run) delete file C:\hMailServer\Attachments\32\{32CE5E4F-E949-4D21-854F-CB38BB0E291D}\emailtest.htm"
2676		"2019-07-07 02:19:08.273"	"(1'st run) delete file C:\hMailServer\Attachments\32\{32CE5E4F-E949-4D21-854F-CB38BB0E291D}\emailtest.asp"
2676		"2019-07-07 02:19:08.273"	"(1'st run) delete file C:\hMailServer\Attachments\32\{32CE5E4F-E949-4D21-854F-CB38BB0E291D}\emailtest.vbs.txt FAILED!"
2676		"2019-07-07 02:19:08.273"	"(1'st run) delete file C:\hMailServer\Attachments\32\{32CE5E4F-E949-4D21-854F-CB38BB0E291D}\wireshark.pcap"
2676		"2019-07-07 02:19:08.273"	"(1'st run) delete file C:\hMailServer\Attachments\32\{32CE5E4F-E949-4D21-854F-CB38BB0E291D}\hmailserver_2019-06-20.log"
2676		"2019-07-07 02:19:08.273"	"(1'st run) delete file C:\hMailServer\Attachments\32\{32CE5E4F-E949-4D21-854F-CB38BB0E291D}\emailtest.log"
2676		"2019-07-07 02:19:08.273"	"(1'st run) delete file C:\hMailServer\Attachments\32\{32CE5E4F-E949-4D21-854F-CB38BB0E291D}\wireshark.out"
2676		"2019-07-07 02:19:08.273"	"(1'st run) Blocked = True"
2676		"2019-07-07 02:19:08.273"	"(1'st run) send mail to Postmaster"
3588		"2019-07-07 02:19:08.461"	"Sub OnDeliverMessage(oMessage)"
3588		"2019-07-07 02:19:08.461"	"(2'nd run) strBaseName = {32CE5E4F-E949-4D21-854F-CB38BB0E291D}"
3588		"2019-07-07 02:19:08.461"	"(2'nd run) strFolder = C:\hMailServer\Attachments\32\{32CE5E4F-E949-4D21-854F-CB38BB0E291D}"
3588		"2019-07-07 02:19:08.461"	"(2'nd run) attach file C:\hMailServer\Attachments\32\{32CE5E4F-E949-4D21-854F-CB38BB0E291D}\CDO-send.vbs"
3588		"2019-07-07 02:19:08.461"	"(2'nd run) attach file C:\hMailServer\Attachments\32\{32CE5E4F-E949-4D21-854F-CB38BB0E291D}\emailtest.html"
3588		"2019-07-07 02:19:08.461"	"(2'nd run) attach file C:\hMailServer\Attachments\32\{32CE5E4F-E949-4D21-854F-CB38BB0E291D}\emailtest.ps1"
3588		"2019-07-07 02:19:08.461"	"(2'nd run) attach file C:\hMailServer\Attachments\32\{32CE5E4F-E949-4D21-854F-CB38BB0E291D}\emailtest.vbs"
3588		"2019-07-07 02:19:08.461"	"(2'nd run) delete folder C:\hMailServer\Attachments\32\{32CE5E4F-E949-4D21-854F-CB38BB0E291D}"
Trace do not match real life emails.

Re: Bug in attachment handling?

Posted: 2019-07-12 21:37
by RvdH
I have no clue how to test your stuff, there are bits en pieces spread out over 3 topics, it doesn't make any sense to me anymore :oops:

Anyway...i tried bits,

Code: Select all

3632	"2019-07-12 21:22:16.047"	"Sub OnDeliveryStart(oMessage)"
3632	"2019-07-12 21:22:16.047"	"(1'st run) strBaseName = {CCC2390C-7279-44AE-BBEE-DC788A5E77BD}"
3632	"2019-07-12 21:22:16.047"	"(1'st run) strFolder = C:\Temp\CC\{CCC2390C-7279-44AE-BBEE-DC788A5E77BD}"
3632	"2019-07-12 21:22:16.063"	"(1'st run) save attachment as C:\Temp\CC\{CCC2390C-7279-44AE-BBEE-DC788A5E77BD}\wireshark.out"
3632	"2019-07-12 21:22:16.063"	"(1'st run) save attachment as C:\Temp\CC\{CCC2390C-7279-44AE-BBEE-DC788A5E77BD}\wireshark.pcap"
3632	"2019-07-12 21:22:16.078"	"(1'st run) save attachment as C:\Temp\CC\{CCC2390C-7279-44AE-BBEE-DC788A5E77BD}\SorenR.LOG"
3632	"2019-07-12 21:22:16.078"	"(1'st run) save attachment as C:\Temp\CC\{CCC2390C-7279-44AE-BBEE-DC788A5E77BD}\SorenR.ASP"
3632	"2019-07-12 21:22:16.094"	"(1'st run) save attachment as C:\Temp\CC\{CCC2390C-7279-44AE-BBEE-DC788A5E77BD}\SorenR.PS1"
3632	"2019-07-12 21:22:16.110"	"(1'st run) save attachment as C:\Temp\CC\{CCC2390C-7279-44AE-BBEE-DC788A5E77BD}\hmailserver_2019-06-20.log"
3632	"2019-07-12 21:22:16.110"	"(1'st run) save attachment as C:\Temp\CC\{CCC2390C-7279-44AE-BBEE-DC788A5E77BD}\CDO-send.vbs"
3632	"2019-07-12 21:22:16.141"	"(1'st run) save attachment as C:\Temp\CC\{CCC2390C-7279-44AE-BBEE-DC788A5E77BD}\SorenR.HTM"
3632	"2019-07-12 21:22:16.156"	"(1'st run) save attachment as C:\Temp\CC\{CCC2390C-7279-44AE-BBEE-DC788A5E77BD}\SorenR.HTML"
3632	"2019-07-12 21:22:16.156"	"(1'st run) save attachment as C:\Temp\CC\{CCC2390C-7279-44AE-BBEE-DC788A5E77BD}\SorenR.VBS"
3632	"2019-07-12 21:22:16.391"	"Sub OnDeliverMessage(oMessage)"
3632	"2019-07-12 21:22:16.406"	"(1'st run) strFolder = C:\temp\CC\{CCC2390C-7279-44AE-BBEE-DC788A5E77BD}"
3632	"2019-07-12 21:22:16.406"	"(1'st run) delete file C:\temp\CC\{CCC2390C-7279-44AE-BBEE-DC788A5E77BD}\wireshark.out"
3632	"2019-07-12 21:22:16.422"	"(1'st run) delete file C:\temp\CC\{CCC2390C-7279-44AE-BBEE-DC788A5E77BD}\wireshark.pcap"
3632	"2019-07-12 21:22:16.422"	"(1'st run) delete file C:\temp\CC\{CCC2390C-7279-44AE-BBEE-DC788A5E77BD}\SorenR.LOG"
3632	"2019-07-12 21:22:16.422"	"(1'st run) delete file C:\temp\CC\{CCC2390C-7279-44AE-BBEE-DC788A5E77BD}\SorenR.ASP"
3632	"2019-07-12 21:22:16.438"	"(1'st run) delete file C:\temp\CC\{CCC2390C-7279-44AE-BBEE-DC788A5E77BD}\SorenR.PS1.txt FAILED!"
3632	"2019-07-12 21:22:16.438"	"(1'st run) delete file C:\temp\CC\{CCC2390C-7279-44AE-BBEE-DC788A5E77BD}\hmailserver_2019-06-20.log"
3632	"2019-07-12 21:22:16.438"	"(1'st run) delete file C:\temp\CC\{CCC2390C-7279-44AE-BBEE-DC788A5E77BD}\CDO-send.vbs.txt FAILED!"
3632	"2019-07-12 21:22:16.453"	"(1'st run) delete file C:\temp\CC\{CCC2390C-7279-44AE-BBEE-DC788A5E77BD}\SorenR.HTM"
3632	"2019-07-12 21:22:16.453"	"(1'st run) delete file C:\temp\CC\{CCC2390C-7279-44AE-BBEE-DC788A5E77BD}\SorenR.HTML"
3632	"2019-07-12 21:22:16.453"	"(1'st run) delete file C:\temp\CC\{CCC2390C-7279-44AE-BBEE-DC788A5E77BD}\SorenR.VBS.txt FAILED!"
3632	"2019-07-12 21:22:16.469"	"(1'st run) Blocked = True"
3632	"2019-07-12 21:22:16.469"	"(1'st run) send mail to Postmaster"
3644	"2019-07-12 21:22:16.875"	"Sub OnDeliverMessage(oMessage)"
3644	"2019-07-12 21:22:16.891"	"(2'nd run) strBaseName = {CCC2390C-7279-44AE-BBEE-DC788A5E77BD}"
3644	"2019-07-12 21:22:16.891"	"(2'nd run) strFolder = C:\temp\CC\{CCC2390C-7279-44AE-BBEE-DC788A5E77BD}"
3644	"2019-07-12 21:22:16.891"	"(2'nd run) attach file C:\temp\CC\{CCC2390C-7279-44AE-BBEE-DC788A5E77BD}\CDO-send.vbs"
3644	"2019-07-12 21:22:16.907"	"(2'nd run) attach file C:\temp\CC\{CCC2390C-7279-44AE-BBEE-DC788A5E77BD}\SorenR.PS1"
3644	"2019-07-12 21:22:16.922"	"(2'nd run) attach file C:\temp\CC\{CCC2390C-7279-44AE-BBEE-DC788A5E77BD}\SorenR.VBS"
3644	"2019-07-12 21:22:16.922"	"(2'nd run) delete folder C:\temp\CC\{CCC2390C-7279-44AE-BBEE-DC788A5E77BD}"
3644	"2019-07-12 21:23:19.071"	"Sub OnDeliveryStart(oMessage)"

Looks good, no?
As soon it gets delivered to postmaster@ attachments are still renamed/replaced with the TXT counter parts, eg:

Code: Select all

The attachment SorenR.PS1 was blocked for delivery by the e-mail server. Please contact your system administrator if you have any questions regarding this.

hMailServer
So whats the point in forwarding to postmaster? hMailServer's Blocked Attachements list still kicks in after

Re: Bug in attachment handling?

Posted: 2019-07-13 00:20
by SorenR
RvdH wrote:
2019-07-12 21:37
I have no clue how to test your stuff, there are bits en pieces spread out over 3 topics, it doesn't make any sense to me anymore :oops:

Anyway...i tried bits,

Code: Select all

3632	"2019-07-12 21:22:16.047"	"Sub OnDeliveryStart(oMessage)"
Looks good, no?
As soon it gets delivered to postmaster@ attachments are still renamed/replaced with the TXT counter parts, eg:

Code: Select all

The attachment SorenR.PS1 was blocked for delivery by the e-mail server. Please contact your system administrator if you have any questions regarding this.

hMailServer
So whats the point in forwarding to postmaster? hMailServer's Blocked Attachements list still kicks in after
The original topic "Working with attachments" is about how to save a copy of a blocked attachment in case of false positive. The original attachment it sent to "a responsible tech person" = Postmaster.
It started out in one direction but that was a dead end so I changed direction. I cannot edit old posts so I have to add updates as posts thus there will be multiple scripts in that thread. Script in last post is most recent.

In this thread I refer to the first thread so not to re-post everything :wink:

Anyways. Log looks fine - When I run it the .html attachment disappears thus it cannot be deleted and is re-attached later. The blocked attachments are all re-attached but when postmaster open the mail there is still a .txt attachment.

Also, my hMailServer block .ps1 AND .vbs, there are 2 .vbs files but I see only 1 <name>.vbs.txt.

In the code I use "oMessage.attachments.Clear" to remove ALL attachments before re-attaching the blocked attachments so there should be NO .txt attachments. The mail to postmaster should ONLY contain the original blocked attachments.

The flow is as follows:
- Original mail save all attachments in unique directory on disk.
- hMailServer remove blocked attachment from mail and change name to <original name>.txt.
- Original mail use list of attachments to delete files from folder. IF a file cannot be deleted, clone the mail and send to postmaster.
- Clear all attachments from cloned mail to postmaster
- Add remaining files from directory (these must be the blocked files) to cloned mail to postmaster.

hMailServer perform the attachments blocking test between "Sub OnDeliveryStart(oMessage)" and "Sub OnDeliverMessage(oMessage)".

The original message is not modified in any way, that is why I thought it safe to put the script in "Sub OnDeliveryStart(oMessage)" and "Sub OnDeliverMessage(oMessage)".

Do not mix this problem with the script to RENAME attachments - it's a completely different case :mrgreen:

Success criteria is Postmaster to receive an email with "[Blocked attachment]" in subject and the cloned email contains ONLY the original "blocked" attachments and the intact BODY message.

Log:

Code: Select all

3568		"2019-07-12 23:41:12.524"	"Sub OnDeliveryStart(oMessage), message from Søren Rathje <soren@acme.inc> to <postmaster@acme.inc>"
3568		"2019-07-12 23:41:12.524"	"(1'st run) strBaseName = {32C9470E-21E3-42E4-BD7E-946991FD89F2}"
3568		"2019-07-12 23:41:12.524"	"(1'st run) strFolder = C:\hMailServer\Attachments\32\{32C9470E-21E3-42E4-BD7E-946991FD89F2}"
3568		"2019-07-12 23:41:12.524"	"(1'st run) save attachment as C:\hMailServer\Attachments\32\{32C9470E-21E3-42E4-BD7E-946991FD89F2}\wireshark.pcap"
3568		"2019-07-12 23:41:12.617"	"(1'st run) save attachment as C:\hMailServer\Attachments\32\{32C9470E-21E3-42E4-BD7E-946991FD89F2}\CDO-send.vbs"
3568		"2019-07-12 23:41:12.617"	"(1'st run) save attachment as C:\hMailServer\Attachments\32\{32C9470E-21E3-42E4-BD7E-946991FD89F2}\emailtest.asp"
3568		"2019-07-12 23:41:12.617"	"(1'st run) save attachment as C:\hMailServer\Attachments\32\{32C9470E-21E3-42E4-BD7E-946991FD89F2}\emailtest.htm"
3568		"2019-07-12 23:41:12.633"	"(1'st run) save attachment as C:\hMailServer\Attachments\32\{32C9470E-21E3-42E4-BD7E-946991FD89F2}\emailtest.html"
3568		"2019-07-12 23:41:12.633"	"(1'st run) save attachment as C:\hMailServer\Attachments\32\{32C9470E-21E3-42E4-BD7E-946991FD89F2}\emailtest.log"
3568		"2019-07-12 23:41:12.649"	"(1'st run) save attachment as C:\hMailServer\Attachments\32\{32C9470E-21E3-42E4-BD7E-946991FD89F2}\emailtest.ps1"
3568		"2019-07-12 23:41:12.649"	"(1'st run) save attachment as C:\hMailServer\Attachments\32\{32C9470E-21E3-42E4-BD7E-946991FD89F2}\emailtest.vbs"
3568		"2019-07-12 23:41:12.649"	"(1'st run) save attachment as C:\hMailServer\Attachments\32\{32C9470E-21E3-42E4-BD7E-946991FD89F2}\hmailserver_2019-06-20.log"
3568		"2019-07-12 23:41:12.664"	"(1'st run) save attachment as C:\hMailServer\Attachments\32\{32C9470E-21E3-42E4-BD7E-946991FD89F2}\wireshark.out"
3568		"2019-07-12 23:41:12.821"	"Sub OnDeliverMessage(oMessage)"
3568		"2019-07-12 23:41:12.821"	"(1'st run) strFolder = C:\hMailServer\Attachments\32\{32C9470E-21E3-42E4-BD7E-946991FD89F2}"
3568		"2019-07-12 23:41:12.821"	"(1'st run) delete file C:\hMailServer\Attachments\32\{32C9470E-21E3-42E4-BD7E-946991FD89F2}\emailtest.ps1.txt FAILED!"
3568		"2019-07-12 23:41:12.821"	"(1'st run) delete file C:\hMailServer\Attachments\32\{32C9470E-21E3-42E4-BD7E-946991FD89F2}\emailtest.htm"
3568		"2019-07-12 23:41:12.836"	"(1'st run) delete file C:\hMailServer\Attachments\32\{32C9470E-21E3-42E4-BD7E-946991FD89F2}\hmailserver_2019-06-20.log"
3568		"2019-07-12 23:41:12.836"	"(1'st run) delete file C:\hMailServer\Attachments\32\{32C9470E-21E3-42E4-BD7E-946991FD89F2}\emailtest.vbs.txt FAILED!"
3568		"2019-07-12 23:41:12.836"	"(1'st run) delete file C:\hMailServer\Attachments\32\{32C9470E-21E3-42E4-BD7E-946991FD89F2}\emailtest.asp"
3568		"2019-07-12 23:41:12.836"	"(1'st run) delete file C:\hMailServer\Attachments\32\{32C9470E-21E3-42E4-BD7E-946991FD89F2}\emailtest.log"
3568		"2019-07-12 23:41:12.836"	"(1'st run) delete file C:\hMailServer\Attachments\32\{32C9470E-21E3-42E4-BD7E-946991FD89F2}\wireshark.pcap"
3568		"2019-07-12 23:41:12.836"	"(1'st run) delete file C:\hMailServer\Attachments\32\{32C9470E-21E3-42E4-BD7E-946991FD89F2}\wireshark.out"
3568		"2019-07-12 23:41:12.836"	"(1'st run) Blocked = True"
3568		"2019-07-12 23:41:12.836"	"(1'st run) send mail to Postmaster"
3028		"2019-07-12 23:41:12.992"	"Sub OnDeliverMessage(oMessage)"
3028		"2019-07-12 23:41:12.992"	"(2'nd run) oMessage.Attachments.Clear -> count = 0"
3028		"2019-07-12 23:41:12.992"	"(2'nd run) strBaseName = {32C9470E-21E3-42E4-BD7E-946991FD89F2}"
3028		"2019-07-12 23:41:12.992"	"(2'nd run) strFolder = C:\hMailServer\Attachments\32\{32C9470E-21E3-42E4-BD7E-946991FD89F2}"
3028		"2019-07-12 23:41:13.039"	"(2'nd run) attach file C:\hMailServer\Attachments\32\{32C9470E-21E3-42E4-BD7E-946991FD89F2}\CDO-send.vbs"
3028		"2019-07-12 23:41:13.039"	"(2'nd run) attach file C:\hMailServer\Attachments\32\{32C9470E-21E3-42E4-BD7E-946991FD89F2}\emailtest.html"
3028		"2019-07-12 23:41:13.039"	"(2'nd run) attach file C:\hMailServer\Attachments\32\{32C9470E-21E3-42E4-BD7E-946991FD89F2}\emailtest.ps1"
3028		"2019-07-12 23:41:13.039"	"(2'nd run) attach file C:\hMailServer\Attachments\32\{32C9470E-21E3-42E4-BD7E-946991FD89F2}\emailtest.vbs"
3028		"2019-07-12 23:41:13.039"	"(2'nd run) delete folder C:\hMailServer\Attachments\32\{32C9470E-21E3-42E4-BD7E-946991FD89F2}"
Code:

Code: Select all

Sub OnDeliveryStart(oMessage)

    'Exit Sub
    
    '
    '   If no attachments, skip!
    '
    If (oMessage.Attachments.Count = 0) Then Exit Sub
    If (oMessage.HeaderValue("X-hMailServer-AttachmentID") <> "") Then Exit Sub
    '
    EventLog.Write( "Sub OnDeliveryStart(oMessage), message from " & oMessage.From & " to " & oMessage.To )
    Dim ATTDIR : ATTDIR = "C:\hMailServer\Attachments"
    '
    Dim i, strBaseName, strFolder
    Dim oFSO : Set oFSO = CreateObject("Scripting.FileSystemObject")
    '
    '   Create unique folder.
    '
    '   Eg: oMessage.Filename = {2B1BE048-D0DA-4743-B723-0C3A2E392134}.eml
    '                  Folder = C:\hMailServer\Attachments\2B\{2B1BE048-D0DA-4743-B723-0C3A2E392134}
    '
    strBaseName = oFSO.GetBaseName(oFSO.GetFile(oMessage.Filename))
    EventLog.Write( "(1'st run) strBaseName = " & strBaseName )
    strFolder = ATTDIR & "\" & UCase(Mid(strBaseName, 2, 2))
    If Not oFSO.FolderExists(strFolder) Then oFSO.CreateFolder strFolder
    strFolder = strFolder & "\" & strBaseName
    EventLog.Write( "(1'st run) strFolder = " & strFolder )
    If Not oFSO.FolderExists(strFolder) Then oFSO.CreateFolder strFolder
    For i = 0 To oMessage.Attachments.Count-1
        EventLog.Write( "(1'st run) save attachment as " & strFolder & "\" & oMessage.Attachments.Item(i).Filename )
        oMessage.Attachments.Item(i).SaveAs( strFolder & "\" & oMessage.Attachments.Item(i).Filename )
    Next
    Set oFSO = Nothing
End Sub

Sub OnDeliverMessage(oMessage)
    
    'Exit Sub
    
    '
    '   If no attachments, skip!
    '
    If (oMessage.Attachments.Count = 0) Then Exit Sub
    '
    EventLog.Write( "Sub OnDeliverMessage(oMessage)" )
    Dim ATTDIR   : ATTDIR   = "C:\hMailServer\Attachments"
    Dim MAILNAME : MAILNAME = "Postmaster"
    Dim MAILADDR : MAILADDR = "postmaster@acme.inc"
    '
    Dim i, strBaseName, strFilename, strFolder, Blocked : Blocked = False
    Dim oFile, oFiles, oFolder, oFSO
    '
    '   Delete saved attachments and mark blocked attachments for handling.
    '
    If (oMessage.HeaderValue("X-hMailServer-AttachmentID") = "") Then
        Set oFSO = CreateObject("Scripting.FileSystemObject")
        strBaseName = oFSO.GetBaseName(oFSO.GetFile(oMessage.Filename))
        strFolder = ATTDIR & "\" & UCase(Mid(strBaseName, 2, 2)) & "\" & strBaseName
        EventLog.Write( "(1'st run) strFolder = " & strFolder )
        On Error Resume Next
        For i = 0 To oMessage.Attachments.Count-1
            oFSO.DeleteFile( strFolder & "\" & oMessage.Attachments.Item(i).Filename )
            If Err.Number = 0 Then 
                EventLog.Write( "(1'st run) delete file " & strFolder & "\" & oMessage.Attachments.Item(i).Filename )
            Else
                Err.Clear
                Blocked = True
                EventLog.Write( "(1'st run) delete file " & strFolder & "\" & oMessage.Attachments.Item(i).Filename & " FAILED!" )
            End If
        Next
        On Error Goto 0
        EventLog.Write( "(1'st run) Blocked = " & Blocked )
        '
        '   Send mail to Postmaster. Blocked file(s) will be attached later.
        '
        If Blocked Then
            EventLog.Write( "(1'st run) send mail to " & MAILNAME )
            With CreateObject("hMailServer.Message")
                strFilename = .Filename
                oFSO.CopyFile oMessage.Filename, strFilename, True
                .RefreshContent
                .AddRecipient MAILNAME, MAILADDR
                .HeaderValue("X-hMailServer-AttachmentID") = strBaseName
                .Subject = "[Blocked attachment] " & .Subject
                .Save
            End With
            Set oFSO = Nothing
            Exit Sub
        End If
        EventLog.Write( "(1'st run) delete folder " & strFolder )
        oFSO.DeleteFolder strFolder
        Set oFSO = Nothing
        Exit Sub
    Else
        '
        '   Clear passed attachments.
        '
        oMessage.Attachments.Clear
        EventLog.Write( "(2'nd run) oMessage.Attachments.Clear -> count = " & oMessage.Attachments.Count )
        strBaseName = oMessage.HeaderValue("X-hMailServer-AttachmentID")
        EventLog.Write( "(2'nd run) strBaseName = " & strBaseName )
        strFolder = ATTDIR & "\" & UCase(Mid(strBaseName, 2, 2)) & "\" & strBaseName
        EventLog.Write( "(2'nd run) strFolder = " & strFolder )
        Set oFSO = CreateObject("Scripting.FileSystemObject")
        Set oFolder = oFSO.GetFolder(strFolder)
        Set oFiles = oFolder.Files
        '
        '   Re-attach blocked file(s) and delete folder.
        '
        For Each oFile In oFiles
            EventLog.Write( "(2'nd run) attach file " & strFolder & "\" & oFile.Name )
            oMessage.Attachments.add(strFolder & "\" & oFile.Name)
        Next
        EventLog.Write( "(2'nd run) delete folder " & strFolder )
        oFSO.DeleteFolder strFolder
        oMessage.Headers.ItemByName("X-hMailServer-AttachmentID").Delete
        oMessage.Save
        Set oFile = Nothing
        Set oFiles = Nothing
        Set oFolder = Nothing
        Set oFSO = Nothing
    End If
End Sub
Attachments and actual emails:
Postmaster INBOX.zip
(1.35 MiB) Downloaded 30 times

Re: Bug in attachment handling?

Posted: 2019-07-13 02:29
by RvdH
Looks fine again...maybe you should upgrade your Outlook version? :mrgreen: (I am using Outlook 2013)

Code: Select all

3644	"2019-07-13 02:17:56.324"	"Sub OnDeliveryStart(oMessage)"
3644	"2019-07-13 02:17:56.340"	"(1'st run) strBaseName = {2520A7DD-F61A-436B-9BCF-6ADFC5F599D7}"
3644	"2019-07-13 02:17:56.340"	"(1'st run) strFolder = C:\Temp\25\{2520A7DD-F61A-436B-9BCF-6ADFC5F599D7}"
3644	"2019-07-13 02:17:56.340"	"(1'st run) save attachment as C:\Temp\25\{2520A7DD-F61A-436B-9BCF-6ADFC5F599D7}\emailtest.asp"
3644	"2019-07-13 02:17:56.402"	"(1'st run) save attachment as C:\Temp\25\{2520A7DD-F61A-436B-9BCF-6ADFC5F599D7}\emailtest.htm"
3644	"2019-07-13 02:17:56.418"	"(1'st run) save attachment as C:\Temp\25\{2520A7DD-F61A-436B-9BCF-6ADFC5F599D7}\emailtest.html"
3644	"2019-07-13 02:17:56.433"	"(1'st run) save attachment as C:\Temp\25\{2520A7DD-F61A-436B-9BCF-6ADFC5F599D7}\emailtest.log"
3644	"2019-07-13 02:17:56.449"	"(1'st run) save attachment as C:\Temp\25\{2520A7DD-F61A-436B-9BCF-6ADFC5F599D7}\emailtest.ps1"
3644	"2019-07-13 02:17:56.465"	"(1'st run) save attachment as C:\Temp\25\{2520A7DD-F61A-436B-9BCF-6ADFC5F599D7}\emailtest.vbs"
3644	"2019-07-13 02:17:56.511"	"(1'st run) save attachment as C:\Temp\25\{2520A7DD-F61A-436B-9BCF-6ADFC5F599D7}\hmailserver_2019-06-20.log"
3644	"2019-07-13 02:17:56.527"	"(1'st run) save attachment as C:\Temp\25\{2520A7DD-F61A-436B-9BCF-6ADFC5F599D7}\wireshark.out"
3644	"2019-07-13 02:17:56.558"	"(1'st run) save attachment as C:\Temp\25\{2520A7DD-F61A-436B-9BCF-6ADFC5F599D7}\wireshark.pcap"
3644	"2019-07-13 02:17:56.668"	"(1'st run) save attachment as C:\Temp\25\{2520A7DD-F61A-436B-9BCF-6ADFC5F599D7}\CDO-send.vbs"
3644	"2019-07-13 02:17:56.980"	"Sub OnDeliverMessage(oMessage)"
3644	"2019-07-13 02:17:56.980"	"(1'st run) strFolder = C:\temp\25\{2520A7DD-F61A-436B-9BCF-6ADFC5F599D7}"
3644	"2019-07-13 02:17:56.980"	"(1'st run) delete file C:\temp\25\{2520A7DD-F61A-436B-9BCF-6ADFC5F599D7}\emailtest.asp"
3644	"2019-07-13 02:17:56.996"	"(1'st run) delete file C:\temp\25\{2520A7DD-F61A-436B-9BCF-6ADFC5F599D7}\emailtest.htm"
3644	"2019-07-13 02:17:56.996"	"(1'st run) delete file C:\temp\25\{2520A7DD-F61A-436B-9BCF-6ADFC5F599D7}\emailtest.html"
3644	"2019-07-13 02:17:56.996"	"(1'st run) delete file C:\temp\25\{2520A7DD-F61A-436B-9BCF-6ADFC5F599D7}\emailtest.log"
3644	"2019-07-13 02:17:57.012"	"(1'st run) delete file C:\temp\25\{2520A7DD-F61A-436B-9BCF-6ADFC5F599D7}\emailtest.ps1.txt FAILED!"
3644	"2019-07-13 02:17:57.012"	"(1'st run) delete file C:\temp\25\{2520A7DD-F61A-436B-9BCF-6ADFC5F599D7}\emailtest.vbs.txt FAILED!"
3644	"2019-07-13 02:17:57.012"	"(1'st run) delete file C:\temp\25\{2520A7DD-F61A-436B-9BCF-6ADFC5F599D7}\hmailserver_2019-06-20.log"
3644	"2019-07-13 02:17:57.027"	"(1'st run) delete file C:\temp\25\{2520A7DD-F61A-436B-9BCF-6ADFC5F599D7}\wireshark.out"
3644	"2019-07-13 02:17:57.027"	"(1'st run) delete file C:\temp\25\{2520A7DD-F61A-436B-9BCF-6ADFC5F599D7}\wireshark.pcap"
3644	"2019-07-13 02:17:57.027"	"(1'st run) delete file C:\temp\25\{2520A7DD-F61A-436B-9BCF-6ADFC5F599D7}\CDO-send.vbs.txt FAILED!"
3644	"2019-07-13 02:17:57.043"	"(1'st run) Blocked = True"
3644	"2019-07-13 02:17:57.043"	"(1'st run) send mail to Postmaster"
3632	"2019-07-13 02:17:57.574"	"Sub OnDeliverMessage(oMessage)"
3632	"2019-07-13 02:17:57.590"	"(2'nd run) strBaseName = {2520A7DD-F61A-436B-9BCF-6ADFC5F599D7}"
3632	"2019-07-13 02:17:57.590"	"(2'nd run) strFolder = C:\temp\25\{2520A7DD-F61A-436B-9BCF-6ADFC5F599D7}"
3632	"2019-07-13 02:17:57.590"	"(2'nd run) attach file C:\temp\25\{2520A7DD-F61A-436B-9BCF-6ADFC5F599D7}\CDO-send.vbs"
3632	"2019-07-13 02:17:57.605"	"(2'nd run) attach file C:\temp\25\{2520A7DD-F61A-436B-9BCF-6ADFC5F599D7}\emailtest.ps1"
3632	"2019-07-13 02:17:57.605"	"(2'nd run) attach file C:\temp\25\{2520A7DD-F61A-436B-9BCF-6ADFC5F599D7}\emailtest.vbs"
3632	"2019-07-13 02:17:57.621"	"(2'nd run) delete folder C:\temp\25\{2520A7DD-F61A-436B-9BCF-6ADFC5F599D7}"
Ahum, i have to excuse myself for my earlier remark about blocked attachment being attached as TXT replacements....my postmaster@ was an alias to info@, which held a forward to ruud@ :oops: :oops: :oops:

Re: Bug in attachment handling?

Posted: 2019-07-13 10:43
by SorenR
RvdH wrote:
2019-07-13 02:29
Looks fine again...maybe you should upgrade your Outlook version? :mrgreen: (I am using Outlook 2013)
I tried sending the same email from GMail - with the same result. PLUS, I noticed when sending mail as HTML the body is cleared :roll:

I'm still on an old version of hMailServer and the Boost libraries have been updated since so that may explain some of it. I will dig deeper once I get my new server up running.

Something is definitively fishy here ;-)

Re: Bug in attachment handling?

Posted: 2019-07-13 10:46
by RvdH
Latest test with updated scripts,

Code: Select all

3796	"2019-07-13 10:42:16.029"	"spfverify.exe 40.92.71.102 passed for: EUR03-DB5-obe.outbound.protection.outlook.com"
3644	"2019-07-13 10:42:46.595"	"Sub OnDeliveryStart(oMessage), message from Ruud van den Hout <something@hotmail.com> to "Test" <test@domain.nl>"
3644	"2019-07-13 10:42:46.595"	"(1'st run) strBaseName = {92693252-5E43-4368-AE71-B9AADA144D81}"
3644	"2019-07-13 10:42:46.595"	"(1'st run) strFolder = C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}"
3644	"2019-07-13 10:42:46.611"	"(1'st run) save attachment as C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\wireshark.pcap"
3644	"2019-07-13 10:42:46.720"	"(1'st run) save attachment as C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\CDO-send.vbs"
3644	"2019-07-13 10:42:46.736"	"(1'st run) save attachment as C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\emailtest.asp"
3644	"2019-07-13 10:42:46.751"	"(1'st run) save attachment as C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\emailtest.htm"
3644	"2019-07-13 10:42:46.751"	"(1'st run) save attachment as C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\emailtest.html"
3644	"2019-07-13 10:42:46.767"	"(1'st run) save attachment as C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\emailtest.log"
3644	"2019-07-13 10:42:46.798"	"(1'st run) save attachment as C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\emailtest.ps1"
3644	"2019-07-13 10:42:46.814"	"(1'st run) save attachment as C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\emailtest.vbs"
3644	"2019-07-13 10:42:46.814"	"(1'st run) save attachment as C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\hmailserver_2019-06-20.log"
3644	"2019-07-13 10:42:46.845"	"(1'st run) save attachment as C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\wireshark.out"
3644	"2019-07-13 10:42:47.205"	"Sub OnDeliverMessage(oMessage)"
3644	"2019-07-13 10:42:47.220"	"(1'st run) strFolder = C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}"
3644	"2019-07-13 10:42:47.220"	"(1'st run) delete file C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\wireshark.pcap"
3644	"2019-07-13 10:42:47.220"	"(1'st run) delete file C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\CDO-send.vbs.txt FAILED!"
3644	"2019-07-13 10:42:47.236"	"(1'st run) delete file C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\emailtest.asp"
3644	"2019-07-13 10:42:47.236"	"(1'st run) delete file C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\emailtest.htm"
3644	"2019-07-13 10:42:47.236"	"(1'st run) delete file C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\emailtest.html"
3644	"2019-07-13 10:42:47.251"	"(1'st run) delete file C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\emailtest.log"
3644	"2019-07-13 10:42:47.251"	"(1'st run) delete file C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\emailtest.ps1.txt FAILED!"
3644	"2019-07-13 10:42:47.251"	"(1'st run) delete file C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\emailtest.vbs.txt FAILED!"
3644	"2019-07-13 10:42:47.267"	"(1'st run) delete file C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\hmailserver_2019-06-20.log"
3644	"2019-07-13 10:42:47.267"	"(1'st run) delete file C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\wireshark.out"
3644	"2019-07-13 10:42:47.283"	"(1'st run) Blocked = True"
3644	"2019-07-13 10:42:47.283"	"(1'st run) send mail to Postmaster"
3632	"2019-07-13 10:42:47.861"	"Sub OnDeliverMessage(oMessage)"
3632	"2019-07-13 10:42:47.877"	"(2'nd run) oMessage.Attachments.Clear -> count = 0"
3632	"2019-07-13 10:42:47.877"	"(2'nd run) strBaseName = {92693252-5E43-4368-AE71-B9AADA144D81}"
3632	"2019-07-13 10:42:47.877"	"(2'nd run) strFolder = C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}"
3632	"2019-07-13 10:42:47.892"	"(2'nd run) attach file C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\CDO-send.vbs"
3632	"2019-07-13 10:42:47.892"	"(2'nd run) attach file C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\emailtest.ps1"
3632	"2019-07-13 10:42:47.892"	"(2'nd run) attach file C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\emailtest.vbs"
3632	"2019-07-13 10:42:47.908"	"(2'nd run) delete folder C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}"
3632	"2019-07-13 10:42:47.908"	"(2'nd run) delete folder C:\Temp\92"
3632 "2019-07-13 10:42:47.908" "(2'nd run) delete folder C:\Temp\92"
That is a little bit i added to remove orphaned leftovers

Code: Select all

EventLog.Write( "(2'nd run) delete folder " & oFSO.BuildPath(ATTDIR, UCase(Mid(strBaseName, 2, 2))) )
oFSO.DeleteFolder oFSO.BuildPath(ATTDIR, UCase(Mid(strBaseName, 2, 2)))

Re: Bug in attachment handling?

Posted: 2019-07-13 10:56
by SorenR
RvdH wrote:
2019-07-13 10:46
Latest test with updated scripts,

Code: Select all

3796	"2019-07-13 10:42:16.029"	"spfverify.exe 40.92.71.102 passed for: EUR03-DB5-obe.outbound.protection.outlook.com"
3644	"2019-07-13 10:42:46.595"	"Sub OnDeliveryStart(oMessage), message from Ruud van den Hout <something@hotmail.com> to "Test" <test@domain.nl>"
3644	"2019-07-13 10:42:46.595"	"(1'st run) strBaseName = {92693252-5E43-4368-AE71-B9AADA144D81}"
3644	"2019-07-13 10:42:46.595"	"(1'st run) strFolder = C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}"
3644	"2019-07-13 10:42:46.611"	"(1'st run) save attachment as C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\wireshark.pcap"
3644	"2019-07-13 10:42:46.720"	"(1'st run) save attachment as C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\CDO-send.vbs"
3644	"2019-07-13 10:42:46.736"	"(1'st run) save attachment as C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\emailtest.asp"
3644	"2019-07-13 10:42:46.751"	"(1'st run) save attachment as C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\emailtest.htm"
3644	"2019-07-13 10:42:46.751"	"(1'st run) save attachment as C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\emailtest.html"
3644	"2019-07-13 10:42:46.767"	"(1'st run) save attachment as C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\emailtest.log"
3644	"2019-07-13 10:42:46.798"	"(1'st run) save attachment as C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\emailtest.ps1"
3644	"2019-07-13 10:42:46.814"	"(1'st run) save attachment as C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\emailtest.vbs"
3644	"2019-07-13 10:42:46.814"	"(1'st run) save attachment as C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\hmailserver_2019-06-20.log"
3644	"2019-07-13 10:42:46.845"	"(1'st run) save attachment as C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\wireshark.out"
3644	"2019-07-13 10:42:47.205"	"Sub OnDeliverMessage(oMessage)"
3644	"2019-07-13 10:42:47.220"	"(1'st run) strFolder = C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}"
3644	"2019-07-13 10:42:47.220"	"(1'st run) delete file C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\wireshark.pcap"
3644	"2019-07-13 10:42:47.220"	"(1'st run) delete file C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\CDO-send.vbs.txt FAILED!"
3644	"2019-07-13 10:42:47.236"	"(1'st run) delete file C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\emailtest.asp"
3644	"2019-07-13 10:42:47.236"	"(1'st run) delete file C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\emailtest.htm"
3644	"2019-07-13 10:42:47.236"	"(1'st run) delete file C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\emailtest.html"
3644	"2019-07-13 10:42:47.251"	"(1'st run) delete file C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\emailtest.log"
3644	"2019-07-13 10:42:47.251"	"(1'st run) delete file C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\emailtest.ps1.txt FAILED!"
3644	"2019-07-13 10:42:47.251"	"(1'st run) delete file C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\emailtest.vbs.txt FAILED!"
3644	"2019-07-13 10:42:47.267"	"(1'st run) delete file C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\hmailserver_2019-06-20.log"
3644	"2019-07-13 10:42:47.267"	"(1'st run) delete file C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\wireshark.out"
3644	"2019-07-13 10:42:47.283"	"(1'st run) Blocked = True"
3644	"2019-07-13 10:42:47.283"	"(1'st run) send mail to Postmaster"
3632	"2019-07-13 10:42:47.861"	"Sub OnDeliverMessage(oMessage)"
3632	"2019-07-13 10:42:47.877"	"(2'nd run) oMessage.Attachments.Clear -> count = 0"
3632	"2019-07-13 10:42:47.877"	"(2'nd run) strBaseName = {92693252-5E43-4368-AE71-B9AADA144D81}"
3632	"2019-07-13 10:42:47.877"	"(2'nd run) strFolder = C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}"
3632	"2019-07-13 10:42:47.892"	"(2'nd run) attach file C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\CDO-send.vbs"
3632	"2019-07-13 10:42:47.892"	"(2'nd run) attach file C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\emailtest.ps1"
3632	"2019-07-13 10:42:47.892"	"(2'nd run) attach file C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}\emailtest.vbs"
3632	"2019-07-13 10:42:47.908"	"(2'nd run) delete folder C:\Temp\92\{92693252-5E43-4368-AE71-B9AADA144D81}"
3632	"2019-07-13 10:42:47.908"	"(2'nd run) delete folder C:\Temp\92"
3632 "2019-07-13 10:42:47.908" "(2'nd run) delete folder C:\Temp\92"
That is a little bit i added to remove orphaned leftovers

Code: Select all

EventLog.Write( "(2'nd run) delete folder " & oFSO.BuildPath(ATTDIR, UCase(Mid(strBaseName, 2, 2))) )
oFSO.DeleteFolder oFSO.BuildPath(ATTDIR, UCase(Mid(strBaseName, 2, 2)))
I had left it there on purpose to mimic the account directory structure :mrgreen:

Anyways, .DeleteFolder is finite as in it removes anything below it so you don't need to .DeleteFolder the UUID folder if you delete the 2 letter folder.

Re: Bug in attachment handling?

Posted: 2019-07-13 10:59
by RvdH
SorenR wrote:
2019-07-13 10:56
I had left it there on purpose to mimic the account directory structure :mrgreen:
With what purpose?

Re: Bug in attachment handling?

Posted: 2019-07-13 11:04
by SorenR
RvdH wrote:
2019-07-13 10:59
SorenR wrote:
2019-07-13 10:56
I had left it there on purpose to mimic the account directory structure :mrgreen:
With what purpose?
Because I can ? :mrgreen: 8)

Re: Bug in attachment handling?

Posted: 2019-07-13 11:09
by RvdH
SorenR wrote:
2019-07-13 10:56
Anyways, .DeleteFolder is finite as in it removes anything below it so you don't need to .DeleteFolder the UUID folder if you delete the 2 letter folder.
Yup, figured that out in the meantime :P

Re: Bug in attachment handling?

Posted: 2019-07-13 11:16
by RvdH
BTW, why you use such an old hMailServer version? what are the specific changes you made to your modified 5.4.2 build?
Is it worth, for example to commit that changes to my experimental build?

Re: Bug in attachment handling?

Posted: 2019-07-13 11:28
by SorenR
RvdH wrote:
2019-07-13 11:16
BTW, why you use such an old hMailServer version? what are the specific changes you made to your modified 5.4.2 build?
Is it worth, for example to commit that changes to my experimental build?
Once I have my new server up running I _will_ be upgrading.

Changes are not that many. First the HELO ... I don't finish the greeting with HELP as it can be used to identify hMailServer. I build a proper ending depending on what is chosen.
Second, I have made access to the ThreadID so I can use it in my custom logs.

Third... "It it aint broke, don't fix it" :mrgreen: