Problem with OnAcceptMessage...

Use this forum if you have problems with a hMailServer script, such as hMailServer WebAdmin or code in an event handler.
Post Reply
User avatar
Rainer
Normal user
Normal user
Posts: 166
Joined: 2007-06-21 13:40
Location: Zweibrücken - Germany

Problem with OnAcceptMessage...

Post by Rainer » 2011-11-02 12:55

Hello, is it possible, in the function: OnAcceptMessage to add an additional RecipientCC or RecipientBCC Name?

Kind regards :)
Rainer Noa

Bill48105
Developer
Developer
Posts: 6192
Joined: 2010-04-24 23:16
Location: Michigan, USA

Re: Problem with OnAcceptMessage...

Post by Bill48105 » 2011-11-02 14:22

Hi,
You have the message so you can edit it if desired, just use the mail path & edit the EML in the script before releasing it for delivery.

As far as smtp to/from check out:
http://www.hmailserver.com/forum/viewto ... 20&t=15301
That show examples of viewing/changing the to/from used for DELIVERY vs in the text of the mail use when VIEWING it.
Bill
hMailServer build LIVE on my servers: 5.4-B2014050402
#hmailserver on FreeNode IRC https://webchat.freenode.net/?channels=#hmailserver
*** ABSENT FROM hMail! Those in IRC know how to find me if urgent. ***

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

Re: Problem with OnAcceptMessage...

Post by mattg » 2011-11-02 14:56

Or via the COM API you can add recipients (I think to the SMTP envelope only), add a CC header, or even copy the message and send the copy to only a set recipient.
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
Rainer
Normal user
Normal user
Posts: 166
Joined: 2007-06-21 13:40
Location: Zweibrücken - Germany

Re: Problem with OnAcceptMessage...

Post by Rainer » 2011-11-02 15:03

Hello Bill, I really wanted to do this without editing the email. I tried using AddRecipient/AddRecipientBCC to add a new additional Recipient. The following error returns: Wrong number of arguments or invalid property assignment: 'oMessage.AddRecipient' - Line: 674 Column: 24 - Code: (null) '

Kind regards :)
Rainer Noa

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

Re: Problem with OnAcceptMessage...

Post by mattg » 2011-11-02 15:08

Are you doing it in the form

oMessage.AddRecipient(Name, Address)

Can you please show your AddRecipient line
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
Rainer
Normal user
Normal user
Posts: 166
Joined: 2007-06-21 13:40
Location: Zweibrücken - Germany

Re: Problem with OnAcceptMessage...

Post by Rainer » 2011-11-02 15:15

Hello Bill, here are the lines:

oMessage.AddRecipient "Postmaster@MyDomain.de"
oMessage.Save
oMessage.RefreshContent

Or

oMessage.AddRecipientBCC "Postmaster@MyDomain.de"
oMessage.Save
oMessage.RefreshContent

Kind regards :)
Rainer Noa

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

Re: Problem with OnAcceptMessage...

Post by mattg » 2011-11-02 15:41

Hey Rainer,

(It's Matt not Bill btw)
Rainer wrote:oMessage.AddRecipient "Postmaster@MyDomain.de"
oMessage.Save
oMessage.RefreshContent
should be

Code: Select all

oMessage.AddRecipient "Postmaster", "Postmaster@MyDomain.de"
oMessage.Save
oMessage.RefreshContent
Matt
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
Rainer
Normal user
Normal user
Posts: 166
Joined: 2007-06-21 13:40
Location: Zweibrücken - Germany

Re: Problem with OnAcceptMessage...

Post by Rainer » 2011-11-02 15:43

Hello Matt, the problem is solved:

If IsArray(MyUnerwuenschtArray) Then
For MyOuterRow = 0 To UBound(MyUnerwuenschtArray)
If Len(MyUnerwuenschtArray(MyOuterRow)) > 0 Then
If InStr(1, LCase(oMessage.Subject), LCase(MyUnerwuenschtArray(MyOuterRow)), vbTextCompare) <> 0 Then
'
oMessage.AddRecipient "", "Postmaster@MyDomain.de"
oMessage.Save
Exit For
ElseIf InStr(1, LCase(MyBody), LCase(MyUnerwuenschtArray(MyOuterRow)), vbTextCompare) <> 0 Then
'
oMessage.AddRecipient "", "Postmaster@MyDomain"
oMessage.Save
Exit For
End If
End If
Next
End If


Kind Regards :)
Rainer Noa

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

Re: Problem with OnAcceptMessage...

Post by mattg » 2011-11-02 15:45

Excellent!!

Glad you got it sorted
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

Bill48105
Developer
Developer
Posts: 6192
Joined: 2010-04-24 23:16
Location: Michigan, USA

Re: Problem with OnAcceptMessage...

Post by Bill48105 » 2011-11-03 06:47

Cool you got it Rainer thanks to MATTG helping. :D Btw does AddRecipient add the header to the email too or you were just wanting to add another SMTP recipient?
Bill
hMailServer build LIVE on my servers: 5.4-B2014050402
#hmailserver on FreeNode IRC https://webchat.freenode.net/?channels=#hmailserver
*** ABSENT FROM hMail! Those in IRC know how to find me if urgent. ***

User avatar
Rainer
Normal user
Normal user
Posts: 166
Joined: 2007-06-21 13:40
Location: Zweibrücken - Germany

Re: Problem with OnAcceptMessage...

Post by Rainer » 2011-11-03 08:27

Good morning Bill!
Yes, the extra receiver is included in the header.

Kind regards :)
Rainer Noa

Post Reply