HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

This section contains scripts that hMailServer has contributed with. hMailServer 5 is needed to use these.
Post Reply
User avatar
jimimaseye
Moderator
Moderator
Posts: 8095
Joined: 2011-09-08 17:48

HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by jimimaseye » 2015-11-23 01:34

Often people have users that do not have access to the Hmailadmin program or the Webadmin and consequently those users are unable to access and set their own Autoreply messages (also known as 'Out Of Office' or 'Vacation' messages). The following script allows users to set or cancel their own Autoreply messages by means of simply sending a specially formatted email. It also gives the option of "SCHEDULING" (setting for the future) the message. ie, submit the message and the start date for it to then 'kick in' when that date arrives.

The process involves sending in an email with the required details, and the script updates the account with the changes. It will only allow users to update their own account (the security of this would be on the assumption that users use authentication to send messages and that it will only action of the FROM and TO are equal). The script will send a confirmation email back to the user detailing the action taken or any errors it encounters (allowing the user to review and resend).

WHAT IT DOES

A successful setting will result in an email, for example:
Date: Mon, 23 Nov 2015 00:30:42 +0100
To: barry@domain.com
From: barry@domain.com
Subject: Vacation Message Modified.


Auto Reply Message set. Settings set as:

Start Date: 2015-12-11
Expiry Date: 2015-12-20
Message Set To Expire: True
Vacation Message is Enabled: True

[Subject]:
On holiday

[Message]:
Hello.

I am now out of office until 20th December.

Kind regards


---------------------------------
Administrators can track all submissions (successful or in error) as they are logged in the Hmailserver_events.log. So if someone has a query or complaint in can be found and analysed.

HOW TO USE

1, Create/compose a new PLAIN TEXT email. It must NOT be formatted as only rich text/html, therefore must be sent as, or to include, PLAIN TEXT format (the email will be returned if not).
2, The RECIPIENT must be themselves at the same email address they are sending from (and do not use an alias).
3, The SUBJECT must be whatever Admin has set as the Trigger Subject text - the default is "set vacation") and is not case sensitive.
4, The BODY of the email must be of the following format:
[ENABLE]
yes or no

[STARTDATE]
yyyy-mm-dd

[EXPIRY]
yyyy-mm-dd

[SUBJECT]
Email auto-reply Subject text

[MESSAGE]
Lines of email auto-reply message.

Another line of message

Regards
Barry
(blank lines between sections are ignored and that the sections can appear in any order. Also, section [labels] are also not case sensitive).

TIP: Place a pre-formatted email in the TEMPLATES folder of each user (if your email client has them).

To SET the auto-reply:
Fill out all 5 sections and set [ENABLE] as "yes".

Note that the DATES MUST BE VALID. eg, Dont enter 2016-02-30 as there is NEVER a 30th February!

To CANCEL the current auto-reply settings and remove all future scheduled autoreply messages:
set [ENABLE] to be "no". (Note that all other sections may be left uncompleted if cancelling.) NOTE: Cancelling with 'Enabled=no' will remove future scheduled messages too.

Example of user 'Barry' setting his auto-reply:
(from: barry@domain.com)
to: barry@domain.com

subject: set vacation

[ENABLE]
yes

[STARTDATE]
2015-12-11

[EXPIRY]
2015-12-20

[SUBJECT]
Out Of Office

[MESSAGE]
Hello. Thank you for your email.

I am currently out of office now until 22nd December. Please contact Vera in my absence.

Thanks

Barry
Example of user 'Barry' CANCELLING his auto-reply:
(from: barry@domain.com)
to: barry@domain.com

subject: set vacation

[ENABLE]
no

[STARTDATE]
2015-12-11

[EXPIRY]
2015-12-20

[SUBJECT]
Out Of Office

[MESSAGE]
Hello. Thank you for your email.

I am currently out of office now until 22nd December. Please contact Vera in my absence.

Thanks

Barry
(Remember that when CANCELLING, all other sections (in grey above) are ignored or can simply be omitted or left in, as you wish).


HOW TO IMPLEMENT

5 steps - Easy peazy!.....

There are 2 scripts. I have listed them below (for copy/paste ease) but also they are attached to this post in the file "UserScheduledVacation.zip" if you wish to take them that way. In the zip, the eventhandlers script is called "AppendEventHandlers.vbs". Whatever your choice, then follow these 5 steps:

1, Copy and paste the FIRST script in its entirety in to the bottom of EVENTHANDLERS.VBS script (following normal hmailserver 'script enabling procedure')

2, You must then change 3 variables at the top of the script:
  • a, your Administrator password ("HMPassword=")
    b, (optional) Your chosen word/phrase as your action Trigger Subject ("TriggerSubject=") - currently set as "set vacation" by default and
    c, choice of including the original email subject to your Auto-reply subject (IncludeSubject="NO" - change to "YES" to append). See this recommended rule viewtopic.php?f=21&t=29038 for reasons to consider this option.
3, Then add the following line in to the 'OnAcceptMessage' subsection.
Sub OnAcceptMessage(oClient, oMessage)
  • OutOfOffice oMessage, oClient
End Sub
4, Copy and save the SECOND script ("ScheduledOutOfOffice.vbs") in to a location of your choice. Here too you must then change the following:
  • a, your Administrator password at the top of the script ("HMPassword= ")
    b, the choice of including the original email subject to your Auto-reply subject (IncludeSubject="NO" - change to "YES" to append)
    c, OfficeHoursStartTime on line 4
5, Set a windows TASK MANAGER job to call the "ScheduledOutOfOffice.vbs" script once a day:

NOTE: Ideally you would call this script to activate after the previous days office hours to catch all emails that come in since the user went home.
  • eg, Users finish at 18:00 and is on holiday from tomorrow. All emails coming in from 18:01 should be auto-responded to as part of that absent period.
In this case you should set the Task Scheduler to run on or soon after 18:01 every day (ie, after office hours). IMPORTANT: ensure that the OfficeHoursStartTime parameter is set to reflect the normal office starting hours. The time entered does not need to be exact and can just reflect, for example, 'morning hours' ie 08:00. (This helps determine whether the above advanced trigger is used or not - ie, an early runtime prior to office hours (opposed to after them) will trigger same day and not in advance.).

If your business does not operate a regular office hours that suits all users then you schedule the script to be called in the early hours (after midnight) and BEFORE normal working office hours in order to set the Autoreply messages in effect for the start of that working day.

In Task Scheduler you simply call:
  • Action: "START A PROGRAM"
    program/script: "c:\pathto\ScheduledOutOfOffice.vbs"
If this script is not run or remains unimplemented then the 'scheduled' vacation messages will not be actioned.

It should be noted that these scripts store the scheduled messages in a file called "ScheduledOutOfOffice.txt" and is stored in the ROOT of the data directory. DO NOT DELETE it (or you will lose all scheduled entries).


The code (click 'SELECT ALL' and copy/paste):

for EVENTHANDLERS.VBS

Code: Select all

Sub OutOfOffice(oMessage,oClient)
   Dim HMPassword, IncludeSubject, SubjSuffix, TriggerSubject, TempTxt
   HMPassword = "secretpassword"
   TriggerSubject = "set vacation"
   IncludeSubject = "NO"       ' Change to "YES" to append original subject text to reply subject

   Dim obApp, objFSO, PathStore
   Set obApp = CreateObject("hMailServer.Application")
   Call obApp.Authenticate("Administrator", HMPassword )
   PathStore = obApp.Settings.Directories.DataDirectory
   If lcase(IncludeSubject) = "yes" then SubjSuffix = " - %SUBJECT%"

   If InStr(1, oMessage.To, oMessage.fromaddress, 1) > 0 and oMessage.Recipients(0).IsLocalUser = true and trim(lcase(oMessage.subject))=trim(lcase(TriggerSubject)) and oClient.Username <> "" then
      if not oMessage.body = "" then
         StartDateOn = "no"
         SubjectOn = "no"
         MessageOn = "no"
         ExpiryOn = "no"
         EnableOn = "no"
         StartDateErrText = "[STARTDATE] section missing"
         StartDateErr = "yes"
         SubjectErrText = "[SUBJECT] section missing"
         SubjectErr = "yes"
         MessageErrText = "[MESSAGE] section missing"
         MessageErr = "yes"
         ExpiryErrText = "[EXPIRY] section missing"
         ExpiryErr = "yes"
         EnableErrText = "[ENABLE] section missing"
         EnableErr = "yes"
         GeneralErr = "no"

         Dim CreateGUIDval, obUtilities
         Set obUtilities = CreateObject("hMailServer.Utilities")
         ScheduleFile = PathStore & "\" & "ScheduledOutOfOffice.txt"
         TempParamFile = PathStore & "\" & Mid(obUtilities.GenerateGUID, 2, 36) & ".txt"
         TempSchedFile = PathStore & "\" & Mid(obUtilities.GenerateGUID, 2, 36) & ".txt"

         Set objFSO = CreateObject("Scripting.FileSystemObject")
         Set objTextFile = objFSO.OpenTextFile(TempParamFile, 2, true)
         objTextFile.WriteLine(oMessage.body)
         objTextFile.Close
      
         Dim VacationStartDate
         Dim VacationSubjectText
         Dim VacationMessageText
         Dim VacationExpiryDate
         count = 0
       
         Set oRead = objFSO.OpenTextFile(TempParamFile, 1)
         Do Until oRead.AtEndOfStream
            MessageInputLine = oRead.ReadLine
            count = count + 1   
            if trim(ucase(MessageInputLine))="[STARTDATE]" or trim(ucase(MessageInputLine))="[EXPIRY]" or trim(ucase(MessageInputLine))="[SUBJECT]" _
             or trim(ucase(MessageInputLine)) = "[MESSAGE]" or trim(ucase(MessageInputLine))="[ENABLE]" then

               if trim(ucase(MessageInputLine)) = "[STARTDATE]" then
                  if not StartDateOn = "no" then
                     StartDateErrText = "Duplication [STARTDATE] header entry - Line=" & count
                     StartDateErr = "yes"
                     StartDateOn = "done"
                  else
                     StartDateOn = "yes"
                     StartDateErrText = "Missing or invalid STARTDATE parameter (VALID date required). - Line=" & count
                  End if
                  if EnableOn = "yes" then EnableOn = "done"
                  if SubjectOn = "yes" then SubjectOn = "done"
                  if MessageOn = "yes" then MessageOn = "done"
                  if ExpiryOn = "yes" then ExpiryOn = "done"
               End if

               if trim(ucase(MessageInputLine)) = "[ENABLE]" then
                  if not EnableOn = "no" then
                     EnableErrText = "Duplication [ENABLE] header entry - Line=" & count
                     EnableErr = "yes"
                     EnableOn = "done"
                  else
                     EnableOn = "yes"
                     EnableErrText = "Missing or invalid ENABLE parameter (YES or NO required). - Line=" & count
                  End if
                  if StartDateOn = "yes" then StartDateOn = "done"
                  if SubjectOn = "yes" then SubjectOn = "done"
                  if MessageOn = "yes" then MessageOn = "done"
                  if ExpiryOn = "yes" then ExpiryOn = "done"
               End if

               if trim(ucase(MessageInputLine)) = "[SUBJECT]" then
                  if not SubjectOn = "no" then
                     SubjectErrText = "Duplication [SUBJECT] header entry - Line=" & count
                     SubjectErr = "yes"
                     SubjectOn = "done"
                  else
                     SubjectOn = "yes"
                     SubjectErrText = "Missing or invalid Subject for Out Of Office message - Line=" & count
                  End if
                  if StartDateOn = "yes" then StartDateOn = "done"
                  if MessageOn = "yes" then MessageOn = "done"
                  if ExpiryOn = "yes" then ExpiryOn = "done"
                  if EnableOn = "yes" then EnableOn = "done"
               End if

               if trim(ucase(MessageInputLine)) = "[EXPIRY]" then
                  if not ExpiryOn = "no" then
                     ExpiryErrText = "Duplicate [EXPIRY] entry - Line=" & count
                     ExpiryErr = "yes"
                     ExpiryOn = "done"
                  else
                     ExpiryOn = "yes"
                     ExpiryErrText = "Missing or invalid Expiry Date - Line=" & count
                  End if
                  if StartDateOn = "yes" then StartDateOn = "done"
                  if MessageOn = "yes" then MessageOn = "done"
                  if SubjectOn = "yes" then SubjectOn = "done"
                  if EnableOn = "yes" then EnableOn = "done"
               End If

               if trim(ucase(MessageInputLine)) = "[MESSAGE]" then
                  if not MessageOn = "no" then
                     MessageErrText = "Duplicate [MESSAGE] entry - Line=" & count
                     MessageErr = "yes"
                     MessageOn = "done"
                  else
                     MessageOn = "yes"
                     MessageErrText = "Missing 'Message' details"
                  End if
               End if
            else
               if StartDateOn = "yes" or SubjectOn = "yes" or ExpiryOn = "yes" or MessageOn = "yes" or EnableOn = "yes" then
                  if StartDateOn = "yes" then
                     If not MessageInputLine = "" then
                        MessageInputLine = replace(trim(MessageInputLine), " ","-")
                        VacationStartDate = replace(trim(MessageInputLine), ".","-")
                        if IsNumeric(mid(VacationStartDate,1,4)) = false or IsNumeric(mid(VacationStartDate,6,2)) = false or _
                        IsNumeric(mid(VacationStartDate,9,2)) = false or isdate(VacationStartDate) = false or len(VacationStartDate) <> 10 then
                           StartDateErrText = "INVALID START DATE. Date doesnt exist or wrong format (requires yyyy-mm-dd) - " & VacationStartDate
                           StartDateErr = "yes"
                        else
                           if DateDiff("d", VacationStartDate, Now()) > 0 then ' Start in the the past
                              StartDateErrText = "START DATE set to past date. Start Date must be today or in the future. - " & VacationStartDate
                              StartDateErr = "yes"
                           else
                              StartDateErrText = ""
                              StartDateErr = "no"
                           End If
                        End if
                        StartDateOn = "done"
                     End if
                  End if
                  if EnableOn = "yes" then
                     If trim(lcase(MessageInputLine)) = "yes" or trim(lcase(MessageInputLine)) = "no" then
                        EnableFlag = MessageInputLine
                        EnableErrText = ""
                        EnableErr = "no"
                     End if
                     EnableOn = "done"
                  End if
                  if SubjectOn = "yes" then
                     If not MessageInputLine = "" then
                        VacationSubjectText = MessageInputLine
                        SubjectErrText = ""
                        SubjectErr = "no"
                     End if
                     SubjectOn = "done"
                  End if
                  if ExpiryOn = "yes" then
                     If not MessageInputLine = "" then
                        MessageInputLine = replace(trim(MessageInputLine), " ","-")
                        VacationExpiryDate = replace(trim(MessageInputLine), ".","-")
                        if IsNumeric(mid(VacationExpiryDate,1,4)) = false or IsNumeric(mid(VacationExpiryDate,6,2)) = false or _
                        IsNumeric(mid(VacationExpiryDate,9,2)) = false or isdate(VacationExpiryDate) = false or len(VacationExpiryDate) <> 10 then
                           ExpiryErrText = "INVALID EXPIRY DATE. Date doesnt exist or wrong format (requires yyyy-mm-dd) - " & VacationExpiryDate
                           ExpiryErr = "yes"
                        else
                           if DateDiff("d", VacationExpiryDate, Now()) >= 0 then ' Expiry in the past
                              ExpiryErrText = "EXPIRY DATE set to past date. Expiry Date must be in the future."
                              ExpiryErr = "yes"
                           else
                              ExpiryErrText = ""
                              ExpiryErr = "no"
                           End If
                        End if
                        ExpiryOn = "done"
                     End if
                  End if
                  if MessageOn = "yes" then
                     If MessageInputLine = "" then
                        VacationMessageText = VacationMessageText & vbNewLine
                     Else
                        VacationMessageText = VacationMessageText & MessageInputLine & vbNewLine
                        MessageErrText = ""
                        MessageErr = "no"
                     End If
                  End if
               else
                  if not MessageInputLine = "" then
                     GeneralErrText = "Text out of valid section - Line=" & count & ". Line text='" & MessageInputLine &"'"
                     GeneralErr = "yes"
                  End if
               End if
            End if
         Loop
         if len(VacationMessageText) > 1000 then
            MessageErrText = "[MESSAGE] text too long. Maximum 1000 characters allowed (including <newline> and trailing blank lines). Current message has " _
            & len(VacationMessageText) & " characters."
            MessageErr = "yes"
         End if
         oRead.Close()  ' Close input file
         objFSO.DeleteFile TempParamFile
         if ExpiryErr = "no" and StartDateErr = "no" then
            if DateDiff("d", VacationStartDate, VacationExpiryDate) < 0 then ' Start beyond Expiry date
               StartDateErrText = "EXPIRY DATE set before START DATE. Start Date must be before expiry date."
               StartDateErr = "yes"
            End if
         End if
      else
         SubjectErrText = "Out Of Office Configuration emails must be in PLAIN text format. Please resend as plain text."
         MessageErrText = ""
      End if

      if EnableErr = "yes" or ( ( StartDateErr = "yes" or SubjectErr = "yes" or MessageErr = "yes" or ExpiryErr = "yes" or GeneralErr = "yes" ) _
      and EnableFlag = "yes") then
         eventlog.write(now() & " User Submitted AutoReply - FAILED: User:" & oMessage.fromaddress )
         if StartDateErrText <> "" then eventlog.write( "Start Date Error= " & StartDateErrText )
         if ExpiryErrText <> "" then eventlog.write( "Expiry Date Error= " & ExpiryErrText )
         if SubjectErrText <> "" then eventlog.write( "Subject Error= " & SubjectErrText )
         if EnableErrText <> "" then eventlog.write( "Enable Error=" & EnableErrText )
         if GeneralErrText <> "" then eventlog.write( "General Error=" & GeneralErrText )
         if MessageErrText <> "" then eventlog.write( "Message Error=" & MessageErrText )
         oMessage.subject = "Vacation Message Failed - not set due to errors shown."
         if StartDateErrText <> "" then TempTxt = TempTxt & "Start Date Error= " & StartDateErrText & vbNewLine & vbNewLine
         if SubjectErrText <> "" then TempTxt = TempTxt & "Subject Error= " & SubjectErrText & vbNewLine & vbNewLine
         if EnableErrText <> "" then TempTxt = TempTxt & "Enable Error=" & EnableErrText & vbNewLine
         if MessageErrText <> "" then TempTxt = TempTxt & "Message Error= " & MessageErrText & vbNewLine & vbNewLine
         if ExpiryErrText <> "" then TempTxt = TempTxt & "Expiry Date Error= " & ExpiryErrText & vbNewLine & vbNewLine
         if GeneralErrText <> "" then TempTxt = TempTxt & "General Error=" & GeneralErrText & vbNewLine & vbNewLine
         oMessage.body = TempTxt & "Format should contain sections in any order as follows:" & vbNewLine & _
         "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" & vbNewLine & _
         "[STARTDATE]" & vbNewLine & _
         "yyyy--mm-dd    (*Ensure its a VALID date and not in the past!)" & vbNewLine & vbNewLine & _
         "[ENABLE]" & vbNewLine & _
         "YES  (to set auto-reply with the details below)  or  NO (to cancel auto-reply messages)" & vbNewLine & vbNewLine & _
         "[EXPIRY]" & vbNewLine & _
         "yyyy--mm-dd    (*Ensure its a VALID date!)" & vbNewLine & vbNewLine & _
         "[SUBJECT]" & vbNewLine & _
         "Out Of Office subject text" & vbNewLine & vbNewLine & _
         "[MESSAGE]" & vbNewLine & _
         "Lines of email message1" & vbNewLine & _
         "Lines of email message2" & vbNewLine & _
         "Lines of email message3" & vbNewLine & _
         "etc" & vbNewLine & vbNewLine & _
         "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" & vbNewLine & vbNewLine & "Original Email ------------------------------" & _
         vbNewLine & oMessage.body & "End of Original email ------------------------------"
         oMessage.htmlbody = Replace(oMessage.body, Chr(13), "<br>")
         oMessage.save
      Else
         eventlog.write(now() & " User Submitted AutoReply: User:" & oMessage.fromaddress & ", Enable: " & ucase(EnableFlag) & ", Dates from/to: " _
         & VacationStartDate & " - " & VacationExpiryDate)
         aUsername = Split(oMessage.fromaddress,"@")
         Dim obDomain
         Set obDomain = obApp.Domains.ItemByName(aUsername(1))
         Dim obAccount
         Set obAccount = obDomain.Accounts.ItemByAddress(oMessage.fromaddress)
         if trim(lcase(EnableFlag)) = "yes" then
            if DateDiff("d", VacationStartDate, Now()) < 0 then ' Start in the future so write to file
               Set oScRead = OpenMyFile(ScheduleFile,8)
               oScRead.WriteLine("[ACCOUNT]" & trim(lcase(oMessage.fromaddress)))
               oScRead.WriteLine("[STARTDT]" & trim(VacationStartDate))
               oScRead.WriteLine("[EXPIRY ]" & trim(VacationExpiryDate))
               oScRead.WriteLine("[SUBJECT]" & trim(VacationSubjectText))
               oScRead.WriteLine("[MESSAGE]" & trim(VacationMessageText))
               oScRead.Close()  ' Close input file
               oMessage.body = "Auto Reply Message set for FUTURE ACTIVATION.  Settings set as:" & vbNewLine & vbNewLine & "Start Date: " & VacationStartDate _
               & vbNewLine & "Expiry Date: " & VacationExpiryDate & vbNewLine & "Message Set To Expire: " & "True" & vbNewLine & _
               "Vacation Message is Enabled: " & "Future" & vbNewLine & vbNewLine & "[Subject]:" & vbNewLine & VacationSubjectText & _
               vbNewLine & "[Message]:" & vbNewLine & VacationMessageText & vbNewLine & "---------------------------------"
               oMessage.subject = "Future Vacation Message Set."
               oMessage.htmlbody = Replace(oMessage.body, Chr(13), "<br>")
            else ' update database as start date is today or past
               obAccount.VacationSubject = VacationSubjectText
               obAccount.VacationMessage = VacationMessageText
               obAccount.VacationMessageExpiresDate = VacationExpiryDate
               obAccount.VacationMessageExpires = True
               obAccount.VacationMessageIsOn = True
               oMessage.body = "Auto Reply Message set.  Settings received and set as follows:" & vbNewLine & vbNewLine & "Expiry Date: " & _
               obAccount.VacationMessageExpiresDate & vbNewLine & "Message Set To Expire: " & obAccount.VacationMessageExpires & vbNewLine & _
               "Vacation Message is Enabled: " & obAccount.VacationMessageIsOn & vbNewLine & vbNewLine & "[Subject]:" & vbNewLine & obAccount.VacationSubject & _
               vbNewLine & "[Message]:" & vbNewLine & obAccount.VacationMessage & vbNewLine & "---------------------------------"
               oMessage.htmlbody = Replace(oMessage.body, Chr(13), "<br>")
               oMessage.subject = "Vacation Message Modified."
               obAccount.VacationSubject = obAccount.VacationSubject & SubjSuffix
            End if
         else
            Set oSchedFile = objFSO.OpenTextFile(TempSchedFile, 2, true)
            Set oSchedRead = OpenMyFile(ScheduleFile,1)
            Do Until oSchedRead.AtEndOfStream
               SchedInputLine = oSchedRead.ReadLine
               if left(ucase(SchedInputLine),9) = "[ACCOUNT]" then
                  if SchedInputLine = "[ACCOUNT]" & oMessage.fromaddress then
                     CancelSched = "yes"
                  Else
                     CancelSched = "no"
                  End if
               End if
               if CancelSched = "no" then
                  oSchedFile.WriteLine(SchedInputLine)
               End if
            Loop
            oSchedRead.Close()  ' Close input file
            oSchedFile.Close()
            objFSO.DeleteFile ScheduleFile
            objFSO.MoveFile (TempSchedFile), (ScheduleFile)
            obAccount.VacationMessageIsOn = False
            oMessage.body = "Auto Reply Message CANCELLED including all scheduled future settings. Settings with ""ENABLE=NO"" was sent." & vbNewLine & vbNewLine & "Hmailserver Admin."
            oMessage.htmlbody = Replace(oMessage.body, Chr(13), "<br>")
            oMessage.subject = "Vacation Message Cancelled."
         End if
         obAccount.Save
         oMessage.save
      End if ' End if email = set out of office
   End if
End Sub

Function WaitTimer(sec)
   With CreateObject("WScript.Shell")
      .Run "timeout /T " & Int(sec), 0, True
   End With
End Function

Function OpenMyFile(strPath, ioMode)
   With CreateObject("Scripting.FileSystemObject")
      Dim oFile, i
      For i = 0 To 30
         On Error Resume Next
         Set oFile = .OpenTextFile(strPath, ioMode, True)
         If (Not Err.Number = 70) Then
            Set OpenMyFile = oFile
            On Error Goto 0
            Exit For
         End If
         On Error Goto 0
         WaitTimer(1)
      Next
   End With
   Set oFile = Nothing
   If (Err.Number = 70) Then
      EventLog.Write("ERROR: VBScript Function OpenMyFile")
      EventLog.Write("File " & strPath & " is locked and timeout was exceeded.")
      Err.Clear
   ElseIf (Err.Number <> 0) Then
      EventLog.Write("ERROR: VBScript Function OpenMyFile")
      EventLog.Write("Error       : " & Err.Number)
      EventLog.Write("Error (hex) : 0x" & Hex(Err.Number))
      EventLog.Write("Source      : " & Err.Source)
      EventLog.Write("Description : " & Err.Description)
      Err.Clear
   End If
End Function
ScheduledOutOfOffice.vbs

Code: Select all

   Dim HMPassword, Pathstore, TempOutFile, ScheduleFile, IncludeSubject, SubjSuffix, OfficeHoursStartTime
   HMPassword = "secretpassword"
   IncludeSubject = "YES"       ' "YES" to append original subject text to auto-reply subject
   OfficeHoursStartTime = "08:00"

   Dim VacationSubjectText
   Dim VacationMessageText
   Dim VacationExpiryDate
   Dim VacationAccount
   Dim CreateGUIDval, obUtilities, process, TempAccount, diffcheck
   Dim obApp, objFSO, EventLog
   Set obApp = CreateObject("hMailServer.Application")
   Call obApp.Authenticate("Administrator", HMPassword )
   Set EventLog = CreateObject("hMailServer.eventlog")
   PathStore = obApp.Settings.Directories.DataDirectory
   If lcase(IncludeSubject) = "yes" then SubjSuffix = " - %SUBJECT%"
   If time > timevalue(OfficeHoursStartTime) then diffcheck = -1
   Set obUtilities = CreateObject("hMailServer.Utilities")
   Set objFSO = CreateObject("Scripting.FileSystemObject")
   TempOutFile = PathStore & "\" & Mid(obUtilities.GenerateGUID, 2, 36) & ".txt"
   ScheduleFile = PathStore & "\ScheduledOutOfOffice.txt"
   Set objTextFile = objFSO.OpenTextFile(TempOutFile, 2, true)
   Set oRead = OpenMyFile(ScheduleFile,1)
   
   VacationAccount = ""

   'FORMAT
   '[ACCOUNT]user1@domain.com
   '[STARTDT]2015-02-07
   '[EXPIRY ]2016-02-24
   '[SUBJECT]subject text
   '[MESSAGE]message text 1
   'message text2
   '
   'End of message

   Do Until oRead.AtEndOfStream
      MessageInputLine = oRead.ReadLine
      if left(ucase(MessageInputLine),9) = "[ACCOUNT]" then
         if VacationAccount <> "" then
            UpdateDB VacationAccount,VacationExpiryDate,VacationSubjectText,VacationMessageText ' DO THE DATABASE UPDATE
            VacationAccount = ""
         End if
         MessageRead = "off"
         VacationMessageText = ""
         TempAccount = right(MessageInputLine,len(MessageInputLine)-9)
         process="no"
      End if
      if left(ucase(MessageInputLine),9) = "[STARTDT]" then
         StartDate = mid(MessageInputLine,10,10)
         if DateDiff("d", StartDate, Now) >= diffcheck then ' Start date in the past
            process = "yes"
            VacationAccount = TempAccount
         else  ' start date in the future
            objTextFile.WriteLine("[ACCOUNT]" & TempAccount)
         End if
      End if
      if process = "yes" then
         if left(ucase(MessageInputLine),9) = "[EXPIRY ]" then
            ExpiryDateLine = mid(MessageInputLine,10,10)
            if DateDiff("d", ExpiryDateLine, Now) + abs(diffcheck) >= 0 then ' Expiry date in the past
               process = "remove"
               VacationAccount = ""
            else
               VacationExpiryDate = right(MessageInputLine,len(MessageInputLine)-9)
            End if
         End if
         if left(ucase(MessageInputLine),9) = "[SUBJECT]" then
            VacationSubjectText = right(MessageInputLine,len(MessageInputLine)-9)
         End if
         if left(ucase(MessageInputLine),9) = "[MESSAGE]" or MessageRead = "on" then
            if MessageRead = "off" then
               MessageInputLine = replace(MessageInputLine, "[MESSAGE]", "")
               VacationMessageText = VacationMessageText & MessageInputLine
               MessageRead = "on"
            else
               VacationMessageText = VacationMessageText & vbNewLine & MessageInputLine
            End if
         End if
      elseif process = "no" then
         if left(ucase(MessageInputLine),9) <> "[ACCOUNT]" then
            objTextFile.WriteLine(MessageInputLine)
         End if
      End if
   Loop
   if VacationAccount <> "" then
      UpdateDB VacationAccount,VacationExpiryDate,VacationSubjectText,VacationMessageText' DO THE DATABASE UPDATE
   End if
   oRead.Close()  ' Close input file
   objFSO.DeleteFile ScheduleFile
   objTextFile.Close()
   objFSO.MoveFile (TempOutFile), (ScheduleFile)

Sub UpdateDB(VacationAccount,VacationExpiryDate,VacationSubjectText,VacationMessageText)
   if DateDiff("d", StartDate, Now) >= diffcheck and DateDiff("d", ExpiryDateLine, Now) < diffcheck then
      aUsername = Split(VacationAccount,"@")
      Dim obDomain, obAccount, newMessage, HTMLmessageText

      HTMLmessageText= Replace(VacationMessageText, Chr(13), "<br>")
      Set newMessage = CreateObject("hMailServer.Message")
       newMessage.From = "OutOfOffice Reminder <" & VacationAccount &">"
       newMessage.Subject = left(now,10) & " Scheduled Vacation Message activated."
       newMessage.Body = "A previously scheduled auto-reply message has been activated for this email address.  Details are:" & vbNewLine & vbNewLine & _
       "Expires: " & VacationExpiryDate & vbNewLine & vbNewLine & _
       "Subject: " & VacationSubjectText & vbNewLine & _
       "Message: " & vbNewLine & VacationMessageText
       newMessage.htmlBody = Replace(newMessage.Body, Chr(13), "<br>")
       newMessage.AddRecipient VacationAccount, VacationAccount
       newMessage.save

      Set obDomain = obApp.Domains.ItemByName(aUsername(1))
      Set obAccount = obDomain.Accounts.ItemByAddress(VacationAccount)
         obAccount.VacationSubject = VacationSubjectText & SubjSuffix
         obAccount.VacationMessage = VacationMessageText
         obAccount.VacationMessageExpiresDate = VacationExpiryDate
         obAccount.VacationMessageExpires = True
         obAccount.VacationMessageIsOn = True
         obAccount.Save
   End if
End Sub
      
Function WaitTimer(sec)
   With CreateObject("WScript.Shell")
      .Run "timeout /T " & Int(sec), 0, True
   End With
End Function

Function OpenMyFile(strPath, ioMode)
   With CreateObject("Scripting.FileSystemObject")
      Dim oFile, i
      For i = 0 To 30
         On Error Resume Next
         Set oFile = .OpenTextFile(strPath, ioMode, True)
         If (Not Err.Number = 70) Then
            Set OpenMyFile = oFile
            On Error Goto 0
            Exit For
         End If
         On Error Goto 0
         WaitTimer(1)
      Next
   End With
   Set oFile = Nothing
   If (Err.Number = 70) Then
      EventLog.Write("ERROR: VBScript Function OpenMyFile")
      EventLog.Write("File " & strPath & " is locked and timeout was exceeded.")
      Err.Clear
   ElseIf (Err.Number <> 0) Then
      EventLog.Write("ERROR: VBScript Function OpenMyFile")
      EventLog.Write("Error       : " & Err.Number)
      EventLog.Write("Error (hex) : 0x" & Hex(Err.Number))
      EventLog.Write("Source      : " & Err.Source)
      EventLog.Write("Description : " & Err.Description)
      Err.Clear
   End If
End Function
Version 1.18
(Version changelog listed below in thread)

Comments appreciated.
Attachments
UserScheduledVacation.zip
v1.18 - 5 Sep 2017. Contains EventHandlers.vbs as "AppendEventHandlers.vbs" and ScheduleOutOfOffice.vbs
(5.83 KiB) Downloaded 140 times
Last edited by jimimaseye on 2016-01-09 13:57, edited 1 time in total.
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 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

frank70
Normal user
Normal user
Posts: 51
Joined: 2013-06-04 13:49

Re: HOW TO: User submitted Autovacation messages also WITH SCHEDULING without Admin access

Post by frank70 » 2015-11-26 12:55

That's great, I will check it out and report the result.
OS: MS Server 2008 R2 SP1;8GB RAM;FUJITSU PRIMERGY Xeon(R);E3-1220 V2@3.10GHz; Mails:20k per anno,1 domain,40 account + archiv,40 alias,biggest mail account:30GB;hmail 5.4.1-B1951

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

Re: HOW TO: User submitted Autovacation messages also WITH SCHEDULING without Admin access

Post by jimimaseye » 2015-11-26 17:16

v1.2 Minor change. Introduced Admin Password variable placement and minor change fixing issue that may have stopped the 'ScheduleOutOfOffice.vbs' script from running). Might be worth you taking the code again.
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 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

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

Re: HOW TO: User submitted Autovacation messages also WITH SCHEDULING without Admin access

Post by jimimaseye » 2015-11-26 23:26

V1.3 - Code updated. It now validates your START and EXPIRY dates - checking the format and validity of the actual date. Re-download if necessary
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 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

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

Re: HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by jimimaseye » 2015-11-27 00:24

v1.4 - Critical Bug fix - future start dates wasnt APPENDing to schedule file (it was OVERWRITING it and thereby loosing all previous entries. Oops!).
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 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

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

Re: HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by jimimaseye » 2015-11-27 00:50

v1.5 Minor change to code (simplifying) but no functional difference.
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 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

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

Re: HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by jimimaseye » 2015-11-27 11:11

v1.6 Bug fix to ScheduleOutOfOffice to handle multiple qualifying entries of same account (in case people submit multiple future dates and messages that meet TODAYS date for starting)
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 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

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

Re: HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by jimimaseye » 2015-11-29 22:16

v1.7 Date validation improvements to Eventhandlers script.
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 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

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

Re: HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by jimimaseye » 2015-11-30 14:20

v1.8 Modified to more meaningful SUBJECT text in feedback email, and meaningful HTML body for clients that view message bodies in HTML mode.
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 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

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

Re: HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by jimimaseye » 2015-12-01 00:21

Next plan: I will look at having it send an email to the account owner when a previously scheduled autoreply kicks in (in case they set it in advance and forget to cancel it if their circumstances change.)
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 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

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

Re: HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by jimimaseye » 2015-12-01 01:21

v1.9 Code to both ScheduleOutOfOffice.vbs and Eventhandlers (OutOfOffice function) modified to:

a, send email to owners account upon activation of Scheduled message (in case they are unaware/forgot and therefore preventing unwanted Autoreplies)
b, send fully HTML formatted feedback emails containing readable Vacation Message details (in case client is not reading in Plain Text mode - enhancement to v1.8 )

Im getting good at this. :lol:
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 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

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

Re: HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by mattg » 2015-12-01 02:25

jimimaseye wrote:Im getting good at this. :lol:
And having heaps of fun !!
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

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

Re: HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by jimimaseye » 2015-12-01 09:16

mattg wrote:And having heaps of fun !!
Sort of. I'm Ok with logic (if.... then... For. ... etc), googling vbs functions and setting variables but I slow to a crawl when it comes to fully understanding the format and coding the api objects. I have to refer to existing scripts and copy them. And the documentation for the HMS objects really is badly formatted and makes things difficult to read especially as I m already struggling with VBS object formatting/structure. I did BASIC programming years ago before this VB object related stuff came out of its shell.

That said I think this script is very useful especially in a business with many users. Users can stash an email in their templates folder and just fire it off when needed. Simples.
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 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

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

Re: HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by jimimaseye » 2015-12-20 21:52

v 1.10 Both scripts modified: Added the choice (by parameter) of including the original email subject to your Auto-reply subject

IncludeSubject = "NO" - change to "YES" to append the original subject

Useful to prevent Auto-reply messages being sent to Spammers when used with this rule: viewtopic.php?f=21&t=29038
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 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

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

HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by jimimaseye » 2015-12-27 15:15

v1.11 Includes important improvement - update recommended. Both scripts modified:

a, Added check for Messagetext maximum 1000 characters allowed as per the software allowance. (Messagetext above 1000 characters will fail)
b, bugfix: added missing Messagetext error text to EVENT LOG file.
c, Code tidy/simplifying for HTML message body on email notifications.
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 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

rivkinnator
New user
New user
Posts: 4
Joined: 2014-09-15 22:29

Re: HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by rivkinnator » 2015-12-28 15:56

This is great M8! just talked to a few of my colleagues and my direct boss looks like were going to put this into our server. we'll let you know how it goes, and what a heavy load does with it. >500 accounts 1 domain

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

Re: HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by jimimaseye » 2015-12-28 22:17

Cheers for the words. I look forward to hearing your feedback.

I dont envisage there being any problems related to account quantity - it may be 500 accounts but I doubt they all send in their 'set vacation' emails all at exactly the same split second, therefore all will be processed separately as they arrive. (Even if there is more than one at the exact same time hopefully the script will handle the file locking of the control file ok).

Anyway, yes please feedback your observations. Thanks.
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 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

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

Re: HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by jimimaseye » 2016-02-22 23:12

v1.12

Code modified to do automatic lookup of hMailserver program and data directory (removing the need to hard-code it in to the script) - hopefully being universal to all OS language and versions of windows system (by using the environmental variables of %programfiles% and %programfiles(x86)%).

Applies for new installations. (Update of existing installation not required as you will have already have been configured.)
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 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

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

Re: HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by mattg » 2016-02-23 00:31

This is for hMailserver installs

Code: Select all

Dim oApp, FSO, ProgDir, DataDir
Set oApp = CreateObject("hMailServer.Application")
	' Give this script permission to access all
	' hMailServer settings.
Call oApp.Authenticate("Administrator", "TopSecretPassword")

Set FSO = CreateObject("Scripting.FileSystemObject")
ProgDir = oApp.Settings.Directories.ProgramDirectory & "\"
DataDir = oApp.Settings.Directories.DataDirectory & "\"
And so on for all of the hMailsevrer directories.

This comes from the hmailserver.ini


(PS I have installed hMailserver to "C:\hmailserver" on my current machine)
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

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

Re: HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by jimimaseye » 2016-02-23 01:35

Humph!! I see another modification coming on tomorrow. :cry: :cry:

(Thanks for the tip. Every day is a learning day.)
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 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

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

Re: HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by mattg » 2016-02-23 01:55

jimimaseye wrote:(Thanks for the tip. Every day is a learning day.)
Yep

I always say that 'a day where you don't learn something is a day wasted'
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

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

Re: HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by jimimaseye » 2016-02-23 12:17

v1.13 Code modified to both scripts to obtain data directory automatically (and reduce amount of code lines involved). Update not necessary but will help in the future if the HMS data directory is to be relocated.
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 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

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

Re: HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by jimimaseye » 2016-07-27 13:05

v1.14 ScheduleOutOfOffice.vbs changed to allow running the evening before the Autoreply trigger date to enable auto-replying to incoming emails that come in after the user finishes work the day before.
  • eg, Users finish at 18:00 and is on holiday from tomorrow. All emails coming in from 18:01 should be responded to.
To upgrade: reinstall the modified ScheduleOutOfOffice.vbs and refer to installation instructions points (4) and (5).
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 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

manfred
New user
New user
Posts: 27
Joined: 2016-10-29 17:05

Re: HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by manfred » 2016-12-10 19:23

Installed without any issue, thanks for great job!
However my taskplanner seems to have an issue, as the task is marked 'running' even minutes after starttime instesd of and not 'successfully completed':
ScreenShot012.gif
So, tomorrow the same time there will be a problem, as I set the task to :if running, do not start a new instance'.
Any idea?
Thanks

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

Re: HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by jimimaseye » 2016-12-11 11:55

My Task Scheduler settings for the "ScheduledOutOfOffice" job:

Image
Attachments
Capture.JPG
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 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

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

Re: HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by jimimaseye » 2016-12-11 12:00

manfred wrote:Installed without any issue, thanks for great job!
However my taskplanner seems to have an issue, as the task is marked 'running' even minutes after starttime instesd of and not 'successfully completed':

ScreenShot012.gif
So, tomorrow the same time there will be a problem, as I set the task to :if running, do not start a new instance'.
Any idea?
Thanks
Look in process explorer to see if the job is actually running (there would be a CSCRIPT process running somewhere) or press REFRESH in Task Scheduler to see if the status changes back to 'Ready' (often this window doesnt reflect actual running status). Check your program and script path and permissions (make sure the account that your scheduled task runs under can access and write to the file in th data directory). Or try running the VBS script from a CMD window so you can see if there is anything untoward happening. Check the DATA root to see if the ScheduledOutOfOffice.txt file actually exists (it should do if you have already submitted a scheduled job).

Im afraid I cant offer much more advice than that - it would just be a case of picking through things.
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 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

manfred
New user
New user
Posts: 27
Joined: 2016-10-29 17:05

Re: HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by manfred » 2016-12-12 15:13

My task looks the same except that 'do not save PW' was checked, 'run in (optional)' was empty, and that my VBS is in a subdirectory of programs\hmailserver.
OK, I changed the PW setting, and entered a 'run in'.
No change. YES, refresh=F5 is always required in Task Scheduler, at least with my Win7.

Now I moved the VBS to D:\
Still not fine.

Then I checked: 'run with highest privileges'.
Fine now!

Then I moved my VBS back to c:\programs(X86)\hmailserver\subdir
Still working fine.

So the conclusion, 'run with highest privileges' must be checked. Strange... but why care much about.
Thanks!
Manf

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

Re: HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by jimimaseye » 2016-12-12 15:55

There you go - permissions. I think that's because under win7 you have to 'authorise' (make safe) the running of such scripts to prevent accidental running of them by double clicks (a security feature). Your 'running' status would have been the equivalent of it displaying the UAC prompt (which of course you wont see as it is a background task). Might be wrong though. Any case, glad you're going.
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 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

manfred
New user
New user
Posts: 27
Joined: 2016-10-29 17:05

Re: HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by manfred » 2016-12-12 16:04

Suppose you are 100% right.

frank70
Normal user
Normal user
Posts: 51
Joined: 2013-06-04 13:49

Risk and Features

Post by frank70 » 2017-08-30 16:49

Hello, thank you for this fine script. It works very well on an Windows 2008R2 Server with hmail 5.6.4-B2283.
I made some test and I found, that I can activate the vacation function from an other mail account which is not on the hmail server. I used an mail account from an other hoster but with the mail address i wanted to manipulate as sender. That was no problem. I think it is better to use a password in the subject. Perhaps it is possible to check if the message was send from a local account.

I additionally wanted to add some other allowed mail addresses for example the secretary office and added/changed some code in the EventHandlers.vbs. Hope that helps and is right. I am not a visual basic programmer.

Best regards

Frank

Code: Select all

Dim HMPassword, IncludeSubject, SubjSuffix,TriggerSubject,allowedMailAdress
   HMPassword = "...."
   IncludeSubject = "YES"       ' Change to "YES" to append original subject text to reply subject
   TriggerSubject = "set vaction secret 1234"
   allowedMailAdress = "sek1@thedomain.tld:sek2@thedomain.tld"
	
   Dim obApp, objFSO, PathStore
   Set obApp = CreateObject("hMailServer.Application")
   Call obApp.Authenticate("Administrator", HMPassword )
   PathStore = obApp.Settings.Directories.DataDirectory
   If lcase(IncludeSubject) = "yes" then SubjSuffix = " - %SUBJECT%"
   allowedMailAdress = allowedMailAdress & oMessage.To
   If ( InStr(1, allowedMailAdress, oMessage.fromaddress, 1) > 0 ) and lcase(oMessage.subject)=TriggerSubject then
OS: MS Server 2008 R2 SP1;8GB RAM;FUJITSU PRIMERGY Xeon(R);E3-1220 V2@3.10GHz; Mails:20k per anno,1 domain,40 account + archiv,40 alias,biggest mail account:30GB;hmail 5.4.1-B1951

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

Re: HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by jimimaseye » 2017-08-30 18:48

Thank you frank for the feedback.

Yes I can see how that a specific situaton involving an outside email address and forwarding can indeed fool the system as it only checks FROM = TO. I will amend the base code accordingly to ensure that the recipient must be a local user account. I may also tailor it to allow for the Admin to choose his trigger phrase at implementation to allow for their choice of language/wording (instead of the English "SET VACATION").

As for your other suggestions of using a secret word or a separate authorised address I will leave them as part of your post as a proposal to those that want to tailor their system to work in a similar way

Thanks again.
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 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

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

Re: HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by jimimaseye » 2017-08-30 20:10

v1.15

* Updated to allow chosen 'trigger word/phrase' under the variable 'TriggerSubject' (Default is "set vacation")
* Fix to ensure that the sender/recipient address belongs is local to Hmailserver (islocal=true')

Existing users may wish to update the script in EVENTHANDLERS to allow for the new functionality if they require it.
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 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

frank70
Normal user
Normal user
Posts: 51
Joined: 2013-06-04 13:49

Re: HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by frank70 » 2017-09-01 15:04

Thank you for your fast response. That's great.

I test it but anyway i can activate it from a fake email-addresses.

There is also a bug in my extension, because later in your script there is the oMessage.fromaddress used. I had to change this to oMessage.To in your script. Otherwise the autoreply is set for the sender :)

Best regards

Frank
OS: MS Server 2008 R2 SP1;8GB RAM;FUJITSU PRIMERGY Xeon(R);E3-1220 V2@3.10GHz; Mails:20k per anno,1 domain,40 account + archiv,40 alias,biggest mail account:30GB;hmail 5.4.1-B1951

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

Re: HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by jimimaseye » 2017-09-01 16:04

frank70 wrote:Thank you for your fast response. That's great.

I test it but anyway i can activate it from a fake email-addresses.
Thanks Frank. To be clear are you saying that MY script allows setting by fake sender? If so, how? The Autoreply is set against an ACCOUNT - if the acocunt doesnt exist then nothing is set. Are you saying there is a fault with it? (I would appreciate if you could clarify if and what it is).

Thanks
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 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

frank70
Normal user
Normal user
Posts: 51
Joined: 2013-06-04 13:49

Re: HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by frank70 » 2017-09-01 19:44

Hello,
I can still fake the sender. I tried it with a foreign mail account which used a mailadress on the server. And i got a message from the hmail account: "Vacation Message Cancelled."

I don't know what Message.Recipients(0).IsLocalUser = true does, but i think that doesn't help. I think it is better to use something like the following changes.

Code: Select all

Sub OnAcceptMessage(oClient, oMessage)
	call OutOfOffice(oClient,oMessage)
End Sub
....
Function OutOfOffice(oClient,oMessage)
....
If InStr(1, oMessage.To, oMessage.fromaddress, 1) > 0 and [b]oClient.Username <> ""[/b] and trim(lcase(oMessage.subject))=trim(lcase(TriggerSubject)) then

Best Regards

Frank
OS: MS Server 2008 R2 SP1;8GB RAM;FUJITSU PRIMERGY Xeon(R);E3-1220 V2@3.10GHz; Mails:20k per anno,1 domain,40 account + archiv,40 alias,biggest mail account:30GB;hmail 5.4.1-B1951

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

Re: HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by jimimaseye » 2017-09-01 20:06

frank70 wrote:
I can still fake the sender. I tried it with a foreign mail account which used a mailadress on the server. And i got a message from the hmail account: "Vacation Message Cancelled."
From the script:
If InStr(1, oMessage.To, oMessage.fromaddress, 1) > 0 and oMessage.Recipients(0).IsLocalUser = true
Ill explain:
a, "If InStr(1, oMessage.To, oMessage.fromaddress, 1) > 0" = If the FROM ADDRESS matches (is found in) the recipient address (TO)
eg,
From: userA@domain.com - To: userA@domain.com = is a match
From: userA@domain.com - To: userB@domain.com = is not a match

and
b,
" oMessage.Recipients(0).IsLocalUser = true" = if the RECIPIENT (from the envelope) is an account found on the server (ie, local)

eg,
To: AccountOnServer@localdomain.com = is a match
To: user@gmail.com = is not a match

THEREFORE

FROM: user@gmail.com
TO: AccountOnServer@localdomain.com
will fail (FROM doesnt match the TO)

FROM: UserNotOnServer@localdomain.com
TO: UserNotOnServer@localdomain.com
will fail (the recipient is not local)

FROM: user@gmail.com
TO: user@gmail.com (with forwarding to AccountOnServer@localdomain.com)
will fail as the FROM address (which the Autoreply account is taken from) is not a local account and therefore there is no account to set or update.

So can you tell me, using the above examples, what combination you use please?
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 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

frank70
Normal user
Normal user
Posts: 51
Joined: 2013-06-04 13:49

Re: HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by frank70 » 2017-09-01 22:02

Hello,

for example:

the hmail account and mail address is xyz@hmailserver.com

the other account and mail address is myname@myotherdomain.com
with this account i send mails as xyz@hmailserver.com

No one can see if the mail from xyz@hmailserver.com is send from the hmail server or from any other server on the world.

In thunderbird you can use the identities button in the server configuration to add more sender addresses which can be any mail address.

I think oMessage.Recipients(0).IsLocalUser only checks the email address. And i think that oClient.Username checks if the mail comes directly from a local account and not from extern.

Best Regards

Frank
OS: MS Server 2008 R2 SP1;8GB RAM;FUJITSU PRIMERGY Xeon(R);E3-1220 V2@3.10GHz; Mails:20k per anno,1 domain,40 account + archiv,40 alias,biggest mail account:30GB;hmail 5.4.1-B1951

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

Re: HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by jimimaseye » 2017-09-02 12:38

frank70 wrote: In thunderbird you can use the identities button in the server configuration to add more sender addresses which can be any mail address.
Thanks for the explanation Frank.

Ive given it a thought.

It is highly unlikely that the scenario described would be exploited given that someone mischievous would:

a, need to know that the email server is Hmailserver
b, need to know this feature is in operation
b1, need to know the format and how to use the feature
c, need to know what the 'triggersubject' is
d, need to know user account(s) they wish to target are valid

and with this in mind I would be comfortable leaving it as it is. In doing so it would also be a benefit for those (like you) that know how to exploit the system for the good eg, they forgot to set it when they left work and are now stuck in a caravan on a campsite with only their mobile phone and personal emails at hand - they can now manage to send off a trigger for their vacation message.

HOWEVER, ..... I also think that one person that would know all of the above points would be a disgruntled ex-employee who might want the then mess around and cause upset to the business any way they can.

So, in the interest of security, I will make the change to ensure that only authenticated connections (ie, from an email client) can make the changes.

Cheers.
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 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

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

Re: HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by jimimaseye » 2017-09-04 00:10

v1.16
* Change to ensure only authenticated connections can successfully submit a vacation message
* Minor Bug fix to ScheduleOutOfOffice.vbs to ensure writes to Eventlog take place.

Existing users should update both scripts.
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 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

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

Re: HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by jimimaseye » 2017-09-05 00:36

v1.17
* Bug fix and change to to instructions (changing from Function to Sub)
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 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

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

Re: HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by jimimaseye » 2017-09-05 23:49

v1.18
* Change to Waittimer function
* Modification to remove unnecessary lines in the eventlog and error email message (now only showing populated error fields, leaving out the blank ones)

eg
previously:

4796 "2017-09-05 22:10:32.044" "Start Date Error= START DATE set to past date. Start Date must be today or in the future. - 2015-11-30"
4796 "2017-09-05 22:10:32.044" "Expiry Date Error= EXPIRY DATE set to past date. Expiry Date must be in the future."
4796 "2017-09-05 22:10:32.044" "Subject Error= "
4796 "2017-09-05 22:10:32.044" "Enable Error="
4796 "2017-09-05 22:10:32.044" "General Error="
4796 "2017-09-05 22:10:32.044" "Message Error="
Now:

4796 "2017-09-05 22:35:15.265" "05/09/2017 22:35:15 User Submitted AutoReply - FAILED: User:sales@domain.co.uk"
4796 "2017-09-05 22:35:15.280" "Start Date Error= START DATE set to past date. Start Date must be today or in the future. - 2015-11-30"
4796 "2017-09-05 22:35:15.280" "Expiry Date Error= EXPIRY DATE set to past date. Expiry Date must be in the future."
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 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

dvhooren
New user
New user
Posts: 1
Joined: 2019-04-27 13:45

Re: HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by dvhooren » 2019-04-27 13:58

Hi,

I am new here but I want to ask something.
I have implemented all the steps which are described in this post but I notice that at the moment I run the scheduled script, it
empties my ScheduledOutOfOffice.txt which I placed in the Data directory.
After running the file is 0 bytes.

This is what I have done:
  • I placed the ScheduledOutOfOffice.txt in the Data dir of hmailserver
  • I have created the ScheduledOutOfOffice.vbs abd placed it in the Events directory of hmailserver
  • I have uncommented the event onAcceptMessage
  • I have added the following line in onAcceptMessage : OutOfOffice oMessage, oClient
  • I have added the Sub OutOfOffice in the EventHandlers.vbs
Then I have enabled the option in the hmailserver admin tool:
Settings - Advanced - Scripts - Enabled (checked and also clicked on Check Syntax: everything fine)

Then I have added a task in the windows scheduler which should call the ScheduledOutOfOffice.vbs.

So so far I think I have not made any mistakes.

But then a number of things I notice:
  • I have setup an email with the given template
  • I send the mail to myself with the [ENABLED] yes
  • I gave the subject the text which should be read by the trigger
  • I get the email but:
1) I do not get an out of office message
2) running the scheduled task in windows will empty the ScheduledOutOfOffice.txt

What is wrong?
Is there a new script?

Thanks in advance and greetings Danny...

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

Re: HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by jimimaseye » 2019-04-27 21:03

Let's look in to things in steps:

When you send in an email to set (an advance) holiday, do you get a confirmation email stating it is set?

Also, at that point, take a look at the ScheduledOutOfOffice.txt file - does it contain anything?

[Entered by mobile. Excuse my spelling.]
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 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

pravyroxor
New user
New user
Posts: 4
Joined: 2019-05-20 08:30

Re: HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by pravyroxor » 2019-05-20 11:04

Hi, thank you for your hard work and support, auto-reply scripts are working like a charm.
I have only one problem with some perhaps unicode - utf-8 characters in the message / subject sections.
Some characters like ľ š ť ž and Ľ Š Ť Ž are interpreted as µ ą » ľ and Ą © « ®
Perhaps vbs functions like objFSO.OpenTextFile can't corectly use all characters in reading / writing operations.

pravyroxor
New user
New user
Posts: 4
Joined: 2019-05-20 08:30

Re: HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by pravyroxor » 2019-05-20 12:03

Maybe the source encoding is not UTF-8, but Windows-1250.

pravyroxor
New user
New user
Posts: 4
Joined: 2019-05-20 08:30

Re: HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by pravyroxor » 2019-05-23 12:14

I have solved the problem by editing the UpdateDB procedure as follows:

Code: Select all

Sub UpdateDB(VacationAccount,VacationExpiryDate,VacationSubjectText,VacationMessageText)
   if DateDiff("d", StartDate, Now) >= diffcheck and DateDiff("d", ExpiryDateLine, Now) < diffcheck then
      aUsername = Split(VacationAccount,"@")
      Dim obDomain, obAccount, newMessage, HTMLmessageText
	  
		VacationSubjectText = Replace(VacationSubjectText,"µ","ľ")
		VacationSubjectText = Replace(VacationSubjectText,"ą","š")
		VacationSubjectText = Replace(VacationSubjectText,"»","ť")
		VacationSubjectText = Replace(VacationSubjectText,"ľ","ž")
		VacationSubjectText = Replace(VacationSubjectText,"Ą","Ľ")
		VacationSubjectText = Replace(VacationSubjectText,"©","Š")
		VacationSubjectText = Replace(VacationSubjectText,"«","Ť")
		VacationSubjectText = Replace(VacationSubjectText,"®","Ž")
		
		VacationMessageText = Replace(VacationMessageText,"µ","ľ")
		VacationMessageText = Replace(VacationMessageText,"ą","š")
		VacationMessageText = Replace(VacationMessageText,"»","ť")
		VacationMessageText = Replace(VacationMessageText,"ľ","ž")
		VacationMessageText = Replace(VacationMessageText,"Ą","Ľ")
		VacationMessageText = Replace(VacationMessageText,"©","Š")
		VacationMessageText = Replace(VacationMessageText,"«","Ť")
		VacationMessageText = Replace(VacationMessageText,"®","Ž")

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

Re: HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by jimimaseye » 2019-05-23 14:17

Thanks for feeding back.

[Entered by mobile. Excuse my spelling.]
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 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

pravyroxor
New user
New user
Posts: 4
Joined: 2019-05-20 08:30

Re: HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by pravyroxor » 2019-07-09 08:03

Hello folks :)
I'd like to ask you, if there's any way how to delete only one particular future autoreply message ?
For example a user have set up two or three autoreply messages in the future and if he send a cancel message for the first one, all of them will be deleted from ScheduledOutOfOffice.txt.
I confess that I don't understand how the vbs script in EventHandlers.vbs exactly works, and why there're som many copies of ScheduledOutOfOffice.txt in Data folder with GUID like 418B01C7-C1D9-4301-A055-2736A6861E48.txt. Or which part of the script is responsible for deleting stored messages in ScheduledOutOfOffice.txt.
We're working on the webapi application for recording and approvall absences in the workplace and this feature will be very usefull.
Thank you

User avatar
derelvis
Normal user
Normal user
Posts: 42
Joined: 2018-11-19 19:15

Re: HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by derelvis » 2019-08-31 13:24

Great job! Thank you very much for the scripts and the howto :-)
HMS 5.7.0-B2484 (x64) (DB version 5700) - MySQL 8.0.15
ClamWin0.99.4 + Clamd service - SpamAssassin 3.4.1.38
Windows Server 2012 - 64Bit

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

Re: HOW TO: User submitted Autoreply/vacation messages also WITH SCHEDULING without Admin access

Post by jimimaseye » 2019-08-31 15:39

derelvis wrote:
2019-08-31 13:24
Great job! Thank you very much for the scripts and the howto :-)
Thanks.
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 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

Post Reply