Script to save message subject in database

This section contains scripts that hMailServer has contributed with. hMailServer 5 is needed to use these.
Post Reply
behroozak
New user
New user
Posts: 1
Joined: 2023-06-06 17:49

Script to save message subject in database

Post by behroozak » 2023-06-06 17:56

dear hamil users.
as you know hmailserver dose not save message subject in hm_messages table so if you use hmailserver for a big site and many emails it will be so slowly so i will modified hmail server 5.4 source code and saved message_subject and message_hasattatch in hm_messages table.
now i need to update to latest version and i could not compile new version.
can any one help me to write an script to save message_subject and message_hasattatch in my hm_messages table?
i want it happen when message is going to deliver i guess it should happened on OnDeliverMessage event.
thanks for your guide

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

Re: Script to save message subject in database

Post by SorenR » 2023-06-07 00:26

behroozak wrote:
2023-06-06 17:56
dear hamil users.
as you know hmailserver dose not save message subject in hm_messages table so if you use hmailserver for a big site and many emails it will be so slowly so i will modified hmail server 5.4 source code and saved message_subject and message_hasattatch in hm_messages table.
now i need to update to latest version and i could not compile new version.
can any one help me to write an script to save message_subject and message_hasattatch in my hm_messages table?
i want it happen when message is going to deliver i guess it should happened on OnDeliverMessage event.
thanks for your guide
Well...

Code: Select all

SELECT hm_messages.messageid, hm_message_metadata.metadata_subject
FROM hm_messages
JOIN hm_message_metadata ON hm_messages.messageid = hm_message_metadata.metadata_messageid
WHERE hm_message_metadata.metadata_subject = 'Subject to find';
SørenR.

Woke is Marxism advancing through Maoist cultural revolution.

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

Re: Script to save message subject in database

Post by palinka » 2023-06-07 12:02

SorenR wrote:
2023-06-07 00:26
behroozak wrote:
2023-06-06 17:56
dear hamil users.
as you know hmailserver dose not save message subject in hm_messages table so if you use hmailserver for a big site and many emails it will be so slowly so i will modified hmail server 5.4 source code and saved message_subject and message_hasattatch in hm_messages table.
now i need to update to latest version and i could not compile new version.
can any one help me to write an script to save message_subject and message_hasattatch in my hm_messages table?
i want it happen when message is going to deliver i guess it should happened on OnDeliverMessage event.
thanks for your guide
Well...

Code: Select all

SELECT hm_messages.messageid, hm_message_metadata.metadata_subject
FROM hm_messages
JOIN hm_message_metadata ON hm_messages.messageid = hm_message_metadata.metadata_messageid
WHERE hm_message_metadata.metadata_subject = 'Subject to find';
^ doesn't address the attachment thingy. But yeah, the subject is already recorded, of course.
behroozak wrote:
2023-06-06 17:56
dear hamil users.
as you know hmailserver dose not save message subject in hm_messages table so if you use hmailserver for a big site and many emails it will be so slowly so i will modified hmail server 5.4 source code and saved message_subject and message_hasattatch in hm_messages table.
now i need to update to latest version and i could not compile new version.
can any one help me to write an script to save message_subject and message_hasattatch in my hm_messages table?
i want it happen when message is going to deliver i guess it should happened on OnDeliverMessage event.
thanks for your guide
You don't mention the structure of column message_hasattach, but....

Code: Select all

Function GetDatabaseObject()
	Dim oApp : Set oApp = CreateObject("hMailServer.Application")
	Call oApp.Authenticate("Administrator", "supersecretpassword")
	Set GetDatabaseObject = oApp.Database
End Function

Sub OnDeliverMessage(oMessage)
	Dim oDB : Set oDB = GetDatabaseObject
	Dim hasattach : hasattach = False
	Dim strSQL

	If oMessage.Attachments.Count > 0 Then hasattach = True
	strSQL = "UPDATE hm_messages SET message_subject = " & Chr(34) & oMessage.Subject & Chr(34) & ", message_hasattach = " & hasattach & " WHERE messageid = " & Chr(34) & oMessage.ID & Chr(34) & ";"
	Call oDB.ExecuteSQL(strSQL)
	Set oDB = Nothing
End Sub

Post Reply