Need Script : Enable Auto Reply on specific mailbox on weekend

This section contains scripts that hMailServer has contributed with. hMailServer 5 is needed to use these.
Post Reply
PMAMCorp
New user
New user
Posts: 5
Joined: 2017-11-21 19:39

Need Script : Enable Auto Reply on specific mailbox on weekend

Post by PMAMCorp » 2021-05-17 08:10

Hello,

Can someone please help on the script that will enable Auto Reply (Out of office) on specific mailbox over the weekend & will turn off automatically on Monday 6 AM ?

Regards
Kedar Khanderkar

User avatar
jimimaseye
Moderator
Moderator
Posts: 9092
Joined: 2011-09-08 17:48

Re: Need Script : Enable Auto Reply on specific mailbox on weekend

Post by jimimaseye » 2021-05-17 08:42

viewtopic.php?f=20&t=28942

[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

PMAMCorp
New user
New user
Posts: 5
Joined: 2017-11-21 19:39

Re: Need Script : Enable Auto Reply on specific mailbox on weekend

Post by PMAMCorp » 2021-05-20 10:05

Hi,

We tried the above scripted but still it not working, can you suggest is there any wrong in scripts i did any thing wrong. let me know if you need more info.


Regards
PMAM
Attachments
Documents.zip
(6 KiB) Downloaded 13 times

PMAMCorp
New user
New user
Posts: 5
Joined: 2017-11-21 19:39

Re: Need Script : Enable Auto Reply on specific mailbox on weekend

Post by PMAMCorp » 2021-05-25 13:38

Hello Support,

We are getting syntax error when we place the OutofOffice script below sub OnAcceptMessage(oClient, oMessage). Please refer to attached screenshot.

Awaiting for your response.

Regards
Akshay Purabia
Attachments
vbsscript.jpg
syntax error.jpg

gotspatel
Normal user
Normal user
Posts: 125
Joined: 2013-10-08 05:42
Location: INDIA

Re: Need Script : Enable Auto Reply on specific mailbox on weekend

Post by gotspatel » 2021-05-25 14:07

PMAMCorp wrote:
2021-05-25 13:38
Hello Support,

We are getting syntax error when we place the OutofOffice script below sub OnAcceptMessage(oClient, oMessage). Please refer to attached screenshot.

Awaiting for your response.

Regards
Akshay Purabia

sub OnAcceptMessage(oClient, oMessage)

Check that "Sub" is there in your code, it is not visible in image and also the line numbers

EDIT

You have not used the code properly. Check the complete code again.

Code: Select all

Sub OnAcceptMessage(oClient, oMessage)
	Sub OutOfOffice(oMessage,oClient)
End Sub

Code: Select all

Sub OutOfOffice(oMessage,oClient)
   Dim HMPassword, IncludeSubject, SubjSuffix, TriggerSubject, TempTxt
   HMPassword = "test#123"		<-------- You need to change to your hmail password
   TriggerSubject = "set vacation"
   IncludeSubject = "YES"       ' Change to "YES" to append original subject text to reply subject
...........

User avatar
jimimaseye
Moderator
Moderator
Posts: 9092
Joined: 2011-09-08 17:48

Re: Need Script : Enable Auto Reply on specific mailbox on weekend

Post by jimimaseye » 2021-05-25 14:57

As identified by Gotspatel, you have not input the code correctly (you are missing "sub"). Revisit the link/guide and read through carefully.
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

Virinum
Normal user
Normal user
Posts: 161
Joined: 2018-11-23 14:42
Location: Germany

Re: Need Script : Enable Auto Reply on specific mailbox on weekend

Post by Virinum » 2021-05-26 08:25

For turning off auto reply automatically, I've written this script.

Set up a task in Windows Task Scheduler triggered every Monday at 6 AM calling the script like this "autoreply.vbs your@mail 0"

(You can also enable auto reply with this script by calling it like this "autoreply.vbs your@mail 1")

Code: Select all

Const HMSADMINUSER = "USERNAME"
Const HMSADMINPWD = "PASSWORD"

email = WScript.Arguments.Item(0)
command = WScript.Arguments.Item(1)

domain = Split(email, "@")(1)

Dim obApp
Set obApp = CreateObject("hMailServer.Application")

Call obApp.Authenticate(HMSADMINUSER, HMSADMINPWD)

Dim obDomain
Set obDomain = obApp.Domains.ItemByName(domain)

Dim obAccount
Set obAccount = obDomain.Accounts.ItemByAddress(email)

if (command = "1") then
    obAccount.VacationMessageIsOn = true
end if

if (command = "0") then
    obAccount.VacationMessageIsOn = false
end if

obAccount.Save
autoreply.vbs

Post Reply