Problem with oMessage.HeaderValue("Subject")

Use this forum if you have problems with a hMailServer script, such as hMailServer WebAdmin or code in an event handler.
Post Reply
Hotlanta
Normal user
Normal user
Posts: 46
Joined: 2006-12-04 20:46

Problem with oMessage.HeaderValue("Subject")

Post by Hotlanta » 2006-12-06 22:00

Hi everyone. I'm pretty new at scripting within HMailserver, so forgive me if I'm missing something basic here.

I'm having a problem getting oMessage.HeaderValue("Subject") to update when I want it to. I'm using the OnAcceptMessage event to set it, and within the subroutine, it accepts it, but when the message comes down in the mail, it shows the original subject.

For testing purposes, all I'm doing is adding "[HM]" to the front of the subject.

If I modify the header within the subroutine and use it within the text of the reply message, the reply message shows the change, so I know I'm updating it at that point at least. Authenticating didn't help, and I've also tried passing the oMessage object ByRef into the subroutine to see if it was a scoping issue, but that didn't help either.

Here is the code:

Sub OnAcceptMessage(oClient, oMessage)

' modify the subject
oMessage.HeaderValue("Subject")="[HM] " & oMessage.HeaderValue("Subject")

' check if too many attachments
If oMessage.Attachments.Count > 5 Then
Result.Value = 2
Result.Message = "We have a five attachment limit for Subject: " & oMessage.HeaderValue("Subject") & " coming from " & oClient.IPAddress
Else
Result.Value = 0
End If

End Sub
This really seems pretty basic. Any idea what I'm missing?

Regards,

John

User avatar
martin
Developer
Developer
Posts: 6834
Joined: 2003-11-21 01:09
Location: Sweden
Contact:

Post by martin » 2006-12-06 22:08

Hi. You need to call oMessage.Save() for any changes to be saved.

Hotlanta
Normal user
Normal user
Posts: 46
Joined: 2006-12-04 20:46

Post by Hotlanta » 2006-12-06 22:19

Thanks, Martin. That got it.

Is there a repository of example code somewhere on the site? Looking at other people's work is always a great leg up on understanding things...

Regards,

John

User avatar
martin
Developer
Developer
Posts: 6834
Joined: 2003-11-21 01:09
Location: Sweden
Contact:

Post by martin » 2006-12-06 22:24

Nope, not except for the user contributed scripts section in the forum. I've thought about putting together samples, but my time is limited..

Post Reply