want to add text into mail body using script

Use this forum if you have problems with a hMailServer script, such as hMailServer WebAdmin or code in an event handler.
Post Reply
yeohws
New user
New user
Posts: 9
Joined: 2020-04-20 23:00

want to add text into mail body using script

Post by yeohws » 2020-04-20 23:06

Hi all,

I am not programming expert, but need to add some disclaimer into incoming mails from other domains, wondering why the script i used could not work.

Below is my script:

' Sub OnClientConnect(oClient)
' End Sub

' Sub OnSMTPData(oClient, oMessage)
' End Sub

Sub OnAcceptMessage(oClient, oMessage)
oMessage.Body = oMessage.Body & "CAUTION: This email was sent from a third party outside of OMGWHYCANNOTWORK. Please DO NOT click links or open attachments unless you recognize the sender and know the content is safe. If you believe this email is not safe, please forward the email to phishing@OMG"
oMessage.Save
End Sub

' Sub OnDeliveryStart(oMessage)
' End Sub

' Sub OnDeliverMessage(oMessage)
' End Sub

' Sub OnBackupFailed(sReason)
' End Sub

' Sub OnBackupCompleted()
' End Sub

' Sub OnError(iSeverity, iCode, sSource, sDescription)
' End Sub

' Sub OnDeliveryFailed(oMessage, sRecipient, sErrorMessage)
' End Sub

' Sub OnExternalAccountDownload(oFetchAccount, oMessage, sRemoteUID)
' End Sub


I use this hmail server to act as internal mail server after mails from external mail server imported into this server using pop3. But I could not get the text append to work.

Any expert here can help out?

btw, I am using version 5.6.6

Thanks a bunch!

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

Re: want to add text into mail body using script

Post by jimimaseye » 2020-04-20 23:29

As you are importing via pop3 you will need to add using the onexternaldownload section. (Onacceptmessage is fgor smtp messages).

[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

yeohws
New user
New user
Posts: 9
Joined: 2020-04-20 23:00

Re: want to add text into mail body using script

Post by yeohws » 2020-04-21 09:28

OK noted.

Only add the codes in that section, right? The 3 elements no need to change?

yeohws
New user
New user
Posts: 9
Joined: 2020-04-20 23:00

Re: want to add text into mail body using script

Post by yeohws » 2020-04-21 09:49

ok checked into the log

"ERROR" 3004 "2020-04-21 15:45:27.712" "Script Error: Source: Microsoft VBScript runtime error - Error: 800A01C2 - Description: Wrong number of arguments or invalid property assignment: 'OnExternalAccountDownload' - Line: 33 Column: 0 - Code: (null)"
"ERROR" 3004 "2020-04-21 15:47:07.540" "Script Error: Source: Microsoft VBScript runtime error - Error: 800A01C2 - Description: Wrong number of arguments or invalid property assignment: 'OnExternalAccountDownload' - Line: 33 Column: 0 - Code: (null)"
"ERROR" 3004 "2020-04-21 15:47:11.188" "Script Error: Source: Microsoft VBScript runtime error - Error: 800A01C2 - Description: Wrong number of arguments or invalid property assignment: 'OnExternalAccountDownload' - Line: 33 Column: 0 - Code: (null)"
"ERROR" 3136 "2020-04-21 15:47:27.273" "Script Error: Source: Microsoft VBScript runtime error - Error: 800A01A8 - Description: Object required: 'oMessage' - Line: 29 Column: 1 - Code: (null)"
"ERROR" 3136 "2020-04-21 15:47:27.273" "Script Error: Source: Microsoft VBScript runtime error - Error: 800A01A8 - Description: Object required: 'oMessage' - Line: 29 Column: 1 - Code: (null)"
"ERROR" 3136 "2020-04-21 15:47:27.273" "Script Error: Source: Microsoft VBScript runtime error - Error: 800A01A8 - Description: Object required: 'oMessage' - Line: 29 Column: 1 - Code: (null)"
"ERROR" 3136 "2020-04-21 15:47:27.273" "Script Error: Source: Microsoft VBScript runtime error - Error: 800A01A8 - Description: Object required: 'oMessage' - Line: 29 Column: 1 - Code: (null)"
"ERROR" 3136 "2020-04-21 15:47:27.273" "Script Error: Source: Microsoft VBScript runtime error - Error: 800A01A8 - Description: Object required: 'oMessage' - Line: 29 Column: 1 - Code: (null)"
"ERROR" 3136 "2020-04-21 15:47:27.273" "Script Error: Source: Microsoft VBScript runtime error - Error: 800A01A8 - Description: Object required: 'oMessage' - Line: 29 Column: 1 - Code: (null)"
"ERROR" 3136 "2020-04-21 15:47:27.273" "Script Error: Source: Microsoft VBScript runtime error - Error: 800A01A8 - Description: Object required: 'oMessage' - Line: 29 Column: 1 - Code: (null)"
"ERROR" 3136 "2020-04-21 15:47:27.273" "Script Error: Source: Microsoft VBScript runtime error - Error: 800A01A8 - Description: Object required: 'oMessage' - Line: 29 Column: 1 - Code: (null)"
"ERROR" 3004 "2020-04-21 15:47:27.740" "Script Error: Source: Microsoft VBScript runtime error - Error: 800A01C2 - Description: Wrong number of arguments or invalid property assignment: 'OnExternalAccountDownload' - Line: 33 Column: 0 - Code: (null)"

oh no, argument error

yeohws
New user
New user
Posts: 9
Joined: 2020-04-20 23:00

Re: want to add text into mail body using script

Post by yeohws » 2020-04-21 09:52

I only have 31 lines here, where did the line 33 error came from

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

Re: want to add text into mail body using script

Post by jimimaseye » 2020-04-21 10:05

Post the entire contents of your handlers script please.

[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

yeohws
New user
New user
Posts: 9
Joined: 2020-04-20 23:00

Re: want to add text into mail body using script

Post by yeohws » 2020-04-21 10:08

' Sub OnClientConnect(oClient)
' End Sub

' Sub OnSMTPData(oClient, oMessage)
' End Sub

'Sub OnAcceptMessage(oClient, oMessage)
'End Sub

' Sub OnDeliveryStart(oMessage)
' End Sub

' Sub OnDeliverMessage(oMessage)
' End Sub

' Sub OnBackupFailed(sReason)
' End Sub

' Sub OnBackupCompleted()
' End Sub

' Sub OnError(iSeverity, iCode, sSource, sDescription)
' End Sub

' Sub OnDeliveryFailed(oMessage, sRecipient, sErrorMessage)
' End Sub

Sub OnExternalAccountDownload(oMessage)
oMessage.Body = oMessage.Body & "CAUTION: This email was sent from a third party outside of OMGGG. Please DO NOT click links or open attachments unless you recognize the sender and know the content is safe. If you believe this email is not safe, please forward the email to spammm"
oMessage.Save
End Sub


for the rules, i set the condition as mail from : not contain @domain.com, will run function OnExternalAccountDownload

Pop3 mails coming in no problem

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

Re: want to add text into mail body using script

Post by jimimaseye » 2020-04-21 10:17

You have changed the OnExternalAccountDownload parameters. Change it back to

Sub OnExternalAccountDownload(oFetchAccount, oMessage, sRemoteUID)

Also the sub section is run automatically against every message downloaded automatically - you do not need to call it by rules. So for conditioning you should put your condition in the script itself (instead of using a rule).

[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

yeohws
New user
New user
Posts: 9
Joined: 2020-04-20 23:00

Re: want to add text into mail body using script

Post by yeohws » 2020-04-21 10:23

this is the log:


"ERROR" 3120 "2020-04-21 16:21:27.659" "Script Error: Source: Microsoft VBScript runtime error - Error: 800A01C2 - Description: Wrong number of arguments or invalid property assignment: 'OnExternalAccountDownload' - Line: 33 Column: 0 - Code: (null)"
"ERROR" 3120 "2020-04-21 16:21:27.661" "Script Error: Source: Microsoft VBScript runtime error - Error: 800A01C2 - Description: Wrong number of arguments or invalid property assignment: 'OnExternalAccountDownload' - Line: 33 Column: 0 - Code: (null)"
"ERROR" 3120 "2020-04-21 16:21:27.661" "Script Error: Source: Microsoft VBScript runtime error - Error: 800A01C2 - Description: Wrong number of arguments or invalid property assignment: 'OnExternalAccountDownload' - Line: 33 Column: 0 - Code: (null)"
"ERROR" 3120 "2020-04-21 16:21:27.664" "Script Error: Source: Microsoft VBScript runtime error - Error: 800A01C2 - Description: Wrong number of arguments or invalid property assignment: 'OnExternalAccountDownload' - Line: 33 Column: 0 - Code: (null)"
"ERROR" 3120 "2020-04-21 16:21:27.664" "Script Error: Source: Microsoft VBScript runtime error - Error: 800A01C2 - Description: Wrong number of arguments or invalid property assignment: 'OnExternalAccountDownload' - Line: 33 Column: 0 - Code: (null)"
"ERROR" 3120 "2020-04-21 16:21:27.666" "Script Error: Source: Microsoft VBScript runtime error - Error: 800A01C2 - Description: Wrong number of arguments or invalid property assignment: 'OnExternalAccountDownload' - Line: 33 Column: 0 - Code: (null)"
"ERROR" 3120 "2020-04-21 16:21:27.666" "Script Error: Source: Microsoft VBScript runtime error - Error: 800A01C2 - Description: Wrong number of arguments or invalid property assignment: 'OnExternalAccountDownload' - Line: 33 Column: 0 - Code: (null)"
"ERROR" 3120 "2020-04-21 16:21:27.669" "Script Error: Source: Microsoft VBScript runtime error - Error: 800A01C2 - Description: Wrong number of arguments or invalid property assignment: 'OnExternalAccountDownload' - Line: 33 Column: 0 - Code: (null)"
"ERROR" 3120 "2020-04-21 16:21:27.669" "Script Error: Source: Microsoft VBScript runtime error - Error: 800A01C2 - Description: Wrong number of arguments or invalid property assignment: 'OnExternalAccountDownload' - Line: 33 Column: 0 - Code: (null)"
"ERROR" 3120 "2020-04-21 16:21:27.669" "Script Error: Source: Microsoft VBScript runtime error - Error: 800A01C2 - Description: Wrong number of arguments or invalid property assignment: 'OnExternalAccountDownload' - Line: 33 Column: 0 - Code: (null)"
"ERROR" 3120 "2020-04-21 16:21:27.671" "Script Error: Source: Microsoft VBScript runtime error - Error: 800A01C2 - Description: Wrong number of arguments or invalid property assignment: 'OnExternalAccountDownload' - Line: 33 Column: 0 - Code: (null)"
"ERROR" 3120 "2020-04-21 16:21:27.671" "Script Error: Source: Microsoft VBScript runtime error - Error: 800A01C2 - Description: Wrong number of arguments or invalid property assignment: 'OnExternalAccountDownload' - Line: 33 Column: 0 - Code: (null)"

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

Re: want to add text into mail body using script

Post by jimimaseye » 2020-04-21 10:37

Have you removed the rule?

Post the entire contents of your handlers script please.

[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

yeohws
New user
New user
Posts: 9
Joined: 2020-04-20 23:00

Re: want to add text into mail body using script

Post by yeohws » 2020-04-21 10:46

Need to remove the rule?

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

Re: want to add text into mail body using script

Post by jimimaseye » 2020-04-21 10:49

jimimaseye wrote:
2020-04-21 10:17
You have changed the OnExternalAccountDownload parameters. Change it back to

Sub OnExternalAccountDownload(oFetchAccount, oMessage, sRemoteUID)

Also the sub section is run automatically against every message downloaded automatically - you do not need to call it by rules. So for conditioning you should put your condition in the script itself (instead of using a rule).

[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

yeohws
New user
New user
Posts: 9
Joined: 2020-04-20 23:00

Re: want to add text into mail body using script

Post by yeohws » 2020-04-27 11:10

hi thanks for reply. but unfortunately it is still not working.

yeohws
New user
New user
Posts: 9
Joined: 2020-04-20 23:00

Re: want to add text into mail body using script

Post by yeohws » 2020-04-28 15:24

It only works if i use "server sendout" which, any outside email from gmail does not work

Post Reply