Reading oMessage-ID in OnAcceptMessage-Event

Use this forum if you have problems with a hMailServer script, such as hMailServer WebAdmin or code in an event handler.
Post Reply
Normal user
Normal user
Posts: 36
Joined: 2015-03-16 16:22

Reading oMessage-ID in OnAcceptMessage-Event

Post by DataMaster » 2015-04-14 17:41


I hope you can help me.

I am trying to use oMessage.ID in my "OnAcceptMessage"-Event.
I want to change a database entry based on the message ID.

But the ID is always 0. Is the ID not set yet?

I only write into a text file to show my output :)
If you have a better idea how I can "debug" my script, pklease let me know :P

Code: Select all

Sub OnAcceptMessage(oClient, oMessage)
		Set objFSO=CreateObject("Scripting.FileSystemObject")

		' write file
		Set objFile = objFSO.CreateTextFile(outFile,True)
		objFile.WriteLine("ID: " & CStr(oMessage.ID) & " END" & vbCrLf)
   End Sub

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

Re: Reading oMessage-ID in OnAcceptMessage-Event

Post by mattg » 2015-04-14 18:34 ... eptmessage

OnAcceptMessage is executed before hMailServer has accepted the email message and before it has been saved in the database. This means that you cannot access the ID of the message in this event.
Just 'cause I link to a page and say little else doesn't mean I am not being nice.

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

Re: Reading oMessage-ID in OnAcceptMessage-Event

Post by SorenR » 2015-04-14 19:25

OnDeliveryStart should be fine, the message is saved (.ID exists) and it's before Anti-Virus checks and before Global Rules are run.

I run my Custom Logger at "Sub OnDeliverMessage(oMessage)". No messages are moved between IMAPFolders yet even though a Global Rule says so... But that's another story :mrgreen:

“Those who don't know history are doomed to repeat it.”
― Edmund Burke

Normal user
Normal user
Posts: 185
Joined: 2011-08-30 20:16

Re: Reading oMessage-ID in OnAcceptMessage-Event

Post by cblaze22 » 2019-05-07 07:02

Can you call .Save in the OnAcceptMessage to get the ID?

Post Reply