Backup log is messed up after upgrading to v5 from v4.

Use this forum if you have problems with a hMailServer script, such as hMailServer WebAdmin or code in an event handler.
Post Reply
black zero
Normal user
Normal user
Posts: 111
Joined: 2008-08-01 15:26

Backup log is messed up after upgrading to v5 from v4.

Post by black zero » 2009-03-16 03:21

It's awfully formatted on notepad. :(

The old hmail did a good job on formatting a backup log... Is there any specific step I need to take to fix the log format?

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

Re: Backup log is messed up after upgrading to v5 from v4.

Post by mattg » 2009-03-16 04:09

Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

black zero
Normal user
Normal user
Posts: 111
Joined: 2008-08-01 15:26

Re: Backup log is messed up after upgrading to v5 from v4.

Post by black zero » 2009-03-16 05:40

Thank you, will give it a try.

Just to clarify something, this script will delete the log after it successfully sends an email, right?

EDIT:

It does not send any mail.... :( What happened? I've changed all values as specified in 'CHANGE ME' as instructed.

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

Re: Backup log is messed up after upgrading to v5 from v4.

Post by mattg » 2009-03-16 07:09

It sends an e-mail for me (and deletes the log).

What does your hmailserver error log say?
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

black zero
Normal user
Normal user
Posts: 111
Joined: 2008-08-01 15:26

Re: Backup log is messed up after upgrading to v5 from v4.

Post by black zero » 2009-03-16 07:23

Where's the error log located? :(

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

Re: Backup log is messed up after upgrading to v5 from v4.

Post by mattg » 2009-03-16 07:27

In your normal hmailserver log file

C:\Program files\hmailserver\logs\ in a standard installation

It will be called 'ERROR_Hmailserver_yyyy-mm-dd.log'
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

black zero
Normal user
Normal user
Posts: 111
Joined: 2008-08-01 15:26

Re: Backup log is messed up after upgrading to v5 from v4.

Post by black zero » 2009-03-16 08:01

"ERROR" 388 "2009-03-16 10:36:27.085" "Script Error: Source: Microsoft VBScript compilation error - Error: 800A0409 - Description: Unterminated string constant - Line: 4 Column: 65 - Code: const g_sBNFromAddress = " 'CHANGE ME"
"ERROR" 2672 "2009-03-16 10:40:30.820" "Script Error: Source: Microsoft VBScript runtime error - Error: 800A01F4 - Description: Variable is undefined: 'MessageRecipientName' - Line: 33 Column: 3 - Code: (null)"
"ERROR" 224 "2009-03-16 11:02:25.492" "Script Error: Source: Microsoft VBScript runtime error - Error: 800A01F4 - Description: Variable is undefined: 'MessageRecipientName' - Line: 33 Column: 3 - Code: (null)"
"ERROR" 5132 "2009-03-16 11:07:30.226" "Script Error: Source: Microsoft VBScript runtime error - Error: 800A01F4 - Description: Variable is undefined: 'MessageRecipientName' - Line: 33 Column: 3 - Code: (null)"
"ERROR" 6112 "2009-03-16 11:26:26.195" "Script Error: Source: Microsoft VBScript runtime error - Error: 800A01F4 - Description: Variable is undefined: 'MessageRecipientName' - Line: 33 Column: 3 - Code: (null)"

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

Re: Backup log is messed up after upgrading to v5 from v4.

Post by mattg » 2009-03-16 08:21

black zero wrote:"ERROR" 388 "2009-03-16 10:36:27.085" "Script Error: Source: Microsoft VBScript compilation error - Error: 800A0409 - Description: Unterminated string constant - Line: 4 Column: 65 - Code: const g_sBNFromAddress = " 'CHANGE ME"
SO the change me at line 4 hasn't been changed correctly

Make sure that you have the address in double quotes ""
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

black zero
Normal user
Normal user
Posts: 111
Joined: 2008-08-01 15:26

Re: Backup log is messed up after upgrading to v5 from v4.

Post by black zero » 2009-03-16 11:19

"ERROR" 4560 "2009-03-16 14:13:53.320" "Script Error: Source: Microsoft VBScript runtime error - Error: 800A01F4 - Description: Variable is undefined: 'MessageRecipientName' - Line: 33 Column: 3 - Code: (null)"


:(

Now what's that?

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

Re: Backup log is messed up after upgrading to v5 from v4.

Post by mattg » 2009-03-16 13:10

Well what does it say.

Line 33 which is in the Sub OnBackupComplete()

Variable is undefined - 'MessageRecipientName' - Code: (null)

Again, this variable hasn't been set correctly. It should be something in double quotes like "something"
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

black zero
Normal user
Normal user
Posts: 111
Joined: 2008-08-01 15:26

Re: Backup log is messed up after upgrading to v5 from v4.

Post by black zero » 2009-03-17 01:13

This is on line 33:

MessageRecipientName = "Evan"

Tell me what did I do wrong? T.T

^DooM^
Site Admin
Posts: 13861
Joined: 2005-07-29 16:18
Location: UK

Re: Backup log is messed up after upgrading to v5 from v4.

Post by ^DooM^ » 2009-03-17 01:24

did you click the reload script button after making changes?
If at first you don't succeed, bomb disposal probably isn't for you! ヅ

black zero
Normal user
Normal user
Posts: 111
Joined: 2008-08-01 15:26

Re: Backup log is messed up after upgrading to v5 from v4.

Post by black zero » 2009-03-17 01:45

Yes.

And if I disable that line 33, the line 34 is the next error. The log shows the same thing.

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

Re: Backup log is messed up after upgrading to v5 from v4.

Post by mattg » 2009-03-17 02:25

I missed another line... Sorry

I have updated the script, or you can just add the following line under the const declarations at the top

Code: Select all

dim MessageRecipientName, MessageRecipientAddress, MessageSubject
My eventhandlers.vbs is quite large - I was just cutting bits of it out for this script.
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

black zero
Normal user
Normal user
Posts: 111
Joined: 2008-08-01 15:26

Re: Backup log is messed up after upgrading to v5 from v4.

Post by black zero » 2009-03-17 03:04

Code: Select all

"ERROR"	5048	"2009-03-17 08:02:45.179"	"Script Error: Source: Microsoft VBScript runtime error - Error: 800A01F4 - Description: Variable is undefined: 'ReadFileUnicode' - Line: 42 Column: 3 - Code: (null)"

I've applied your fix, and here's the new error log.

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

Re: Backup log is messed up after upgrading to v5 from v4.

Post by mattg » 2009-03-17 03:39

Ah, yep wrong function pasted at the bottom.

Replace the function ReadFile(sFile) with this

Code: Select all

Function ReadFileUnicode(sFile)
	dim fso, f
	Set fso = CreateObject("Scripting.FileSystemObject")
	Set f = fso.OpenTextFile(sFile, 1, false, -1)
	ReadFileUnicode = f.ReadAll
	f.Close
	Set f = Nothing
	Set fso = Nothing
End Function
Again I have updated the post. Thanks for the debug help
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

black zero
Normal user
Normal user
Posts: 111
Joined: 2008-08-01 15:26

Re: Backup log is messed up after upgrading to v5 from v4.

Post by black zero » 2009-03-17 04:25

Here you go. Apparently DeleteFile sub is missing lol.

Code: Select all

"ERROR"	1384	"2009-03-17 09:23:19.851"	"Script Error: Source: Microsoft VBScript runtime error - Error: 800A01F4 - Description: Variable is undefined: 'DeleteFile' - Line: 43 Column: 3 - Code: (null)"

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

Re: Backup log is messed up after upgrading to v5 from v4.

Post by mattg » 2009-03-17 04:32

You have the sub deletefile(sfile) included?
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

black zero
Normal user
Normal user
Posts: 111
Joined: 2008-08-01 15:26

Re: Backup log is messed up after upgrading to v5 from v4.

Post by black zero » 2009-03-17 04:46

EDIT:

My bad, I forgot to include DeleteFile from the original script.

It's working properly now.


Next question: How do I make the script to send the notification to MORE than one recipient?

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

Re: Backup log is messed up after upgrading to v5 from v4.

Post by mattg » 2009-03-17 05:17

Good, glad that it is working for you.

By adding some of these

Code: Select all

   MessageRecipientName1 = "Mail Server"  'CHANGE ME
   MessageRecipientAddress1 = "mailserver@domain.com"  'CHANGE ME
and these

Code: Select all

   oMessage.AddRecipient MessageRecipientName1, MessageRecipientAddress1
changing the number 1 each additional recipient

Let me know if you need further help.
Thanks for debugging for me.
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

black zero
Normal user
Normal user
Posts: 111
Joined: 2008-08-01 15:26

Re: Backup log is messed up after upgrading to v5 from v4.

Post by black zero » 2009-03-17 08:17

Thank you!

I'll PM you if I encounter any problem with the edited script (with more than 1 recipient).

:D Finally I can sleep peacefully.

black zero
Normal user
Normal user
Posts: 111
Joined: 2008-08-01 15:26

Re: Backup log is messed up after upgrading to v5 from v4.

Post by black zero » 2009-03-18 06:53

Code: Select all

"ERROR"	2196	"2009-03-18 11:45:24.882"	"Script Error: Source: Microsoft VBScript runtime error - Error: 800A01C2 - Description: Wrong number of arguments or invalid property assignment: 'oMessage.AddRecipient' - Line: 53 Column: 3 - Code: (null)"

Code: Select all

Option Explicit

const g_sBNFrom = "zero"  'CHANGE ME
const g_sBNFromAddress = "postmasterzero@xxx.co.id"  'CHANGE ME
const g_sAdminPassword = "itsmeadmin"  'CHANGE ME
dim MessageRecipientName, MessageRecipientAddress,MessageRecipientName2, MessageRecipientAddress2, MessageSubject

Sub OnBackupFailed(sReason)
   dim oApp, sBackupLog, oMessage
   Set oApp = CreateObject("hMailServer.Application")
   MessageRecipientName = "Vvvv"   'CHANGE ME
   MessageRecipientAddress = "vvvv@xxx.co.id"   'CHANGE ME
   MessageRecipientName2 = "yyyy"   'CHANGE ME
   MessageRecipientAddress2 = "yyyy@xxx.co.id"
   MessageSubject = "**** Backup FAILED ****"

   ' Give this script permission to access all
   ' hMailServer settings.
   Call oApp.Authenticate("Administrator", g_sAdminPassword)

   sBackupLog = ReadFileUnicode(oApp.Settings.Backup.LogFile)
   DeleteFile(oApp.Settings.Backup.LogFile)

   Set oMessage = CreateObject("hMailServer.Message")
   oMessage.From = g_sBNFrom & " <" & g_sBNFromAddress &  ">"
   oMessage.FromAddress = g_sBNFromAddress
   oMessage.Subject = MessageSubject
   oMessage.AddRecipient MessageRecipientName, MessageRecipientAddress
   oMessage.AddRecipient MessageRecipientName2, MessageRecipientAddress2
   oMessage.Body = "The backup DID NOT COMPLETE succesfully." & vbNewLine & "PLEASE INVESTIGATE" & vbNewLine & sBackupLog
   oMessage.Save
End Sub

Sub OnBackupCompleted()
   dim oApp, sBackupLog, oMessage
   Set oApp = CreateObject("hMailServer.Application")
   MessageRecipientName = "Vvvv"  'CHANGE ME
   MessageRecipientAddress = "vvvv@xxx.co.id"  'CHANGE ME
   MessageRecipientName2 = "yyyy"   'CHANGE ME
   MessageRecipientAddress2 = "yyyy@xxx.co.id"
   MessageSubject = "Hmailserver Backup Completed"

   ' Give this script permission to access all
   ' hMailServer settings.
   Call oApp.Authenticate("Administrator", g_sAdminPassword)

   sBackupLog = ReadFileUnicode(oApp.Settings.Backup.LogFile)
   DeleteFile(oApp.Settings.Backup.LogFile)

   Set oMessage = CreateObject("hMailServer.Message")
   oMessage.From = g_sBNFrom & " <" & g_sBNFromAddress &  ">"
   oMessage.FromAddress = g_sBNFromAddress
   oMessage.Subject = MessageSubject
   oMessage.AddRecipient MessageRecipientName, MessageRecipientAddress
   oMessage.AddRecipient MessageRecipientName2, MessageRecipientAddress2
   oMessage.Body = "The backup completed succesfully." & vbNewLine & vbNewLine & sBackupLog
   oMessage.Save
End Sub

Sub DeleteFile(sFile)
   Dim fso
   Set fso = CreateObject("Scripting.FileSystemObject")
   fso.DeleteFile(sFile)
   Set fso = Nothing
End Sub

Function ReadFileUnicode(sFile)
   dim fso, f
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set f = fso.OpenTextFile(sFile, 1, false, -1)
   ReadFileUnicode = f.ReadAll
   f.Close
   Set f = Nothing
   Set fso = Nothing
End Function
Now what should I do?

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

Re: Backup log is messed up after upgrading to v5 from v4.

Post by mattg » 2009-03-18 07:24

Line 53 is " oMessage.Subject = MessageSubject" which is not the line that has caused the error.

Check that you have reloaded the scripts in hmailserver administrator, and have posted the correct script here please.
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

black zero
Normal user
Normal user
Posts: 111
Joined: 2008-08-01 15:26

Re: Backup log is messed up after upgrading to v5 from v4.

Post by black zero » 2009-03-18 09:07

"ERROR" 4808 "2009-03-18 14:03:34.398" "Script Error: Source: Microsoft VBScript runtime error - Error: 800A01C2 - Description: Wrong number of arguments or invalid property assignment: 'oMessage.AddRecipient' - Line: 53 Column: 3 - Code: (null)"

It is the error log. I reloaded the script and rechecked my code up there, it's same.

And maybe it's a line break that caused you to miscalculate the line?

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

Re: Backup log is messed up after upgrading to v5 from v4.

Post by mattg » 2009-03-18 09:28

Yeah maybe, I was just trying to workout which of the addrecipient lines it was failing at...
Addrecipient needs two arguments and both need to be a string, ie a double quoted selection of letters, numbers and symbols.

I guess you could remark one or the other out to test. To remark out a line put a single apostrophe at the start of the line (')
like this

' oMessage.AddRecipient MessageRecipientName, MessageRecipientAddress
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

black zero
Normal user
Normal user
Posts: 111
Joined: 2008-08-01 15:26

Re: Backup log is messed up after upgrading to v5 from v4.

Post by black zero » 2009-03-19 02:52

After several tests,

It's able to send a notification to one email address only. ~_~

^DooM^
Site Admin
Posts: 13861
Joined: 2005-07-29 16:18
Location: UK

Re: Backup log is messed up after upgrading to v5 from v4.

Post by ^DooM^ » 2009-03-19 03:29

Send it to a distribution list then you can have as many recipients as you want.
If at first you don't succeed, bomb disposal probably isn't for you! ヅ

black zero
Normal user
Normal user
Posts: 111
Joined: 2008-08-01 15:26

Re: Backup log is messed up after upgrading to v5 from v4.

Post by black zero » 2009-03-19 05:38

lol that's brilliant. You should've told me that trick earlier...

Post Reply