Export list of blocked attachments

Use this forum if you have installed hMailServer and want to ask a question related to a production release of hMailServer. Before posting, please read the troubleshooting guide. A large part of all reported issues are already described in detail here.
Post Reply
hermes
New user
New user
Posts: 2
Joined: 2019-11-20 17:16

Export list of blocked attachments

Post by hermes » 2019-11-20 17:39

Hi.

I want to export my list of blocked attachments (configured in the anti-virus settings) to a text file. How could that be done?

Thanks

Hermes

User avatar
RvdH
Senior user
Senior user
Posts: 924
Joined: 2008-06-27 14:42
Location: Netherlands

Re: Export list of blocked attachments

Post by RvdH » 2019-11-20 18:28

Code: Select all

Option Explicit

Public Const ADMIN = "Administrator"
Public Const PASSWORD = "PUT_YOUR_PASSWORD_HERE" 'Password for hMailServer Administrator

Dim fso, file
Const ForWriting = 2 

Set fso = CreateObject("Scripting.FileSystemObject")
set file = fso.OpenTextFile("C:\BlockedAttachments.tmp", ForWriting, true)

Dim obApp, x, obBlockedAttachment 
Set obApp = CreateObject("hMailServer.Application")
Call obApp.Authenticate(ADMIN, PASSWORD)
for x=0 to obApp.Settings.AntiVirus.BlockedAttachments.Count-1
	Set obBlockedAttachment = obApp.Settings.AntiVirus.BlockedAttachments(x)
	file.writeline obBlockedAttachment.Description & " (" & obBlockedAttachment.Wildcard & ")"
	Set obBlockedAttachment = nothing
next
Set obApp = Nothing

fso.CopyFile "C:\BlockedAttachments.tmp" , "C:\BlockedAttachments.txt", true
'fso.DeleteFile "C:\BlockedAttachments.tmp", true
Set fso = nothing
CIDR to RegEx: d-fault.nl/CIDRtoRegEx
DNS Lookup: d-fault.nl/DNSTools
DNSBL Lookup: d-fault.nl/DNSBLLookup
GEOIP Lookup: d-fault.nl/GeoipLookup

hermes
New user
New user
Posts: 2
Joined: 2019-11-20 17:16

Re: Export list of blocked attachments

Post by hermes » 2019-11-20 18:53

Wow. Thank you very much.

User avatar
mattg
Moderator
Moderator
Posts: 20632
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: Export list of blocked attachments

Post by mattg » 2019-12-11 14:39

This particular script can be written in any file with a .vbs extension, and simply double clicked to run

It doesn't need to be a part of your eventhandlers.vbs
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

Post Reply