Syntax

Use this forum if you have problems with a hMailServer script, such as hMailServer WebAdmin or code in an event handler.
Post Reply
usermm
New user
New user
Posts: 5
Joined: 2020-03-25 11:07
Location: Germany

Syntax

Post by usermm » 2020-03-25 11:27

Hello.
Please be so kind and tell me how the following line
has to be written for more specific users:
if oClient.Username = .....
= "" means all of them but I need just a few specific.

Thank you very much.

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

Re: Syntax

Post by RvdH » 2020-03-25 11:31

Uh, what :?:
oClient.Username = "" means a client without a username, eg: unauthenticated

maybe you should search the forum for examples/inspiration
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

usermm
New user
New user
Posts: 5
Joined: 2020-03-25 11:07
Location: Germany

Re: Syntax

Post by usermm » 2020-03-25 11:42

Well, my goal is to block attachments for specific users and therefor
I have to adapt the following script for specific users:
Sub OnAcceptMessage(oClient, oMessage)
' Ignore messages from local users
if oClient.Username = "" then
Dim oAttachment
Dim oRegExp
Set oRegExp = new RegExp
For oAttachment = 0 to oMessage.Attachments.Count-1
' Test for undesirable attachments
with oRegExp
.Pattern = "^.*\.(bat|cmd|com|cpl|csh|docm|exe|hta|htb|inf|js|jse|lnk|msi|msp|pif|reg|scf|scr|shs|shb|vbe|vbs|wsf|wsh|zip)$"
.IgnoreCase = True
.Global = False
end with

Sorry if my English is not very good. (Germany)
Thanks.

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

Re: Syntax

Post by RvdH » 2020-03-25 12:09

Once again....Search :!: :?:

There are plenty of forum topics covering attachment handling that should get you started
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

palinka
Senior user
Senior user
Posts: 1916
Joined: 2017-09-12 17:57

Re: Syntax

Post by palinka » 2020-03-25 13:38


usermm
New user
New user
Posts: 5
Joined: 2020-03-25 11:07
Location: Germany

Re: Syntax

Post by usermm » 2020-03-25 16:40

Thanks.
I'd seen that before but it's not exactly what I need.
There are attachments to be blocked (or not) but
for some specific users only.
And I still don't know how it goes.

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

Re: Syntax

Post by RvdH » 2020-03-25 17:23

What about specifying/defining the usernames?

Code: Select all

If oClient.Username = "username1@domain.com" OR oClient.Username = "username2@domain.com" Then
You are really asking weird questions or asking the obvious, use your brain if you have one and try to put some effort in yourself....search the forums for other examples and test, test & test
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

usermm
New user
New user
Posts: 5
Joined: 2020-03-25 11:07
Location: Germany

Re: Syntax

Post by usermm » 2020-03-25 19:52

You don't have to become unpolite. I'm realy not stupid.
I asked from the beginning what syntax should I use.
In VBA or Excel, for example, is the syntax for defining conditions
or in separating terms very different. And I have a pretty large experience with that.
Nevertheless, thank you.

User avatar
SorenR
Senior user
Senior user
Posts: 3564
Joined: 2006-08-21 15:38
Location: Denmark

Re: Syntax

Post by SorenR » 2020-03-25 21:22

usermm wrote:
2020-03-25 19:52
You don't have to become unpolite. I'm realy not stupid.
I asked from the beginning what syntax should I use.
In VBA or Excel, for example, is the syntax for defining conditions
or in separating terms very different. And I have a pretty large experience with that.
Nevertheless, thank you.
If you have a problem with english try send a message to Dravion, he is german and an excellent developer.
SørenR.

“With age comes wisdom, but sometimes age comes alone.”
- Oscar Wilde

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

Re: Syntax

Post by RvdH » 2020-03-25 21:26

VBA, Excel?

https://www.hmailserver.com/documentati ... ce_scripts
Maybe next time try to consult the documentation first
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

usermm
New user
New user
Posts: 5
Joined: 2020-03-25 11:07
Location: Germany

Re: Syntax

Post by usermm » 2020-03-26 09:06

Thank you SorenR. I'll do this in future.
I hope he might be more friendly and not
as arrogant as some other people here.
And I'm not referring to you, of course...
Thanks again.

Post Reply