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
DataMaster
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

Hello,

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
		outFile="c:\test\scriptoutput.txt"
		Set objFile = objFSO.CreateTextFile(outFile,True)
		objFile.WriteLine("ID: " & CStr(oMessage.ID) & " END" & vbCrLf)
		objFile.Close
   End Sub


User avatar
mattg
Moderator
Moderator
Posts: 20452
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

https://www.hmailserver.com/documentati ... eptmessage
Notes

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.
https://www.hmailserver.com/documentation

User avatar
SorenR
Senior user
Senior user
Posts: 3278
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:
SørenR.

“With age comes wisdom, but sometimes age comes alone.”
- Oscar Wilde

cblaze22
Normal user
Normal user
Posts: 165
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