Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Add text to body and forward email
PostPosted: 2012-01-31 15:16 
New user
New user

Joined: 2012-01-31 15:09
Posts: 1
Hi, I am trying to make script work but cannot work out whats wrong...
I am getting no errors but it is not adding the text to the mail body...

I have a rule setup to check subject and if it contains certain text then..

run function afp
forward email
delete email

the forward and delete work but the function does not, i get no errors but the text is not added to the body, can you help please???

Code:
'   Sub OnClientConnect(oClient)
'   End Sub

'   Sub OnAcceptMessage(oClient, oMessage)
'   End Sub

'   Sub OnDeliveryStart(oMessage)
'   End Sub

'   Sub OnDeliverMessage(oMessage)
'   End Sub

'   Sub OnBackupFailed(sReason)
'   End Sub

'   Sub OnBackupCompleted()
'   End Sub

'   Sub OnError(iSeverity, iCode, sSource, sDescription)
'   End Sub

'   Sub OnDeliveryFailed(oMessage, sRecipient, sErrorMessage)
'   End Sub

'   Sub OnExternalAccountDownload(oMessage, sRemoteUID)
'   End Sub

Function afp(oMessage)

frontpage = "{frontpage}"
   
oMessage.body = frontpage & VBNewLine & VBNewLine & oMessage.body
             
      oMessage.save
End Function


Top
 Profile  
 
 Post subject: Re: Add text to body and forward email
PostPosted: 2012-02-01 14:01 
Moderator
User avatar

Joined: 2007-06-14 05:12
Posts: 11881
Location: 'The Outback' Australia
Message.body is plain text body
Did you take that into account?

What is the exact value of your "{frontpage}"

_________________
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
Documentation


Top
 Profile  
 
 Post subject: Re: Add text to body and forward email
PostPosted: 2012-03-02 11:00 
New user
New user

Joined: 2012-03-02 10:16
Posts: 4
Hi,

My first post so bear with me :-)

I am having a similar problem where I try to modify the subject and as above it all runs just the message subject does not get modified.

I have a "core" account that gets the POP mail and delivers it to the MIME recipient.
I have an account that receives the mail and runs a rule to: call the function ChangeSubject, forward the mail, delete the mail

Code:
Sub ChangeSubject(oMessage)

  oMessage.Subject = "New Subject"
  oMessage.Save
 
End Sub


The mail gets forwared but the subject does not change :-(

I am running on Win7 Enterprise 64bit.

Regards


Top
 Profile  
 
 Post subject: Re: Add text to body and forward email
PostPosted: 2012-03-02 14:44 
Moderator
User avatar

Joined: 2007-06-14 05:12
Posts: 11881
Location: 'The Outback' Australia
did you -
Put your script in the eventhandlers.vbs?
Reload Scripts?
Enable logging? (what do the logs say?)

Also, try making this a function, not a sub

_________________
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
Documentation


Top
 Profile  
 
 Post subject: Re: Add text to body and forward email
PostPosted: 2012-03-02 22:19 
New user
New user

Joined: 2012-03-02 10:16
Posts: 4
Hi,

Had tried all the other things except using a Function instead of a Sub and guess what that worked. However, this was only a prelude to what I actually wanted to do which was to get hMailServer to reply with my WAN address instead of using Dynamic DNS and this is what I came up with:

Code:
Function GetMyIP(oMessage)

  Dim lngStatus, objHTTP, objMatch, objRE, strText, strURL, strMyIP
  Dim oNewMessage

  ' Return value in case the IP address could not be retrieved
  strMyIP = "0.0.0.0"

  ' Retrieve the URL's text
  strURL = "http://automation.whatismyip.com/n09230945.asp"
  Set objHTTP = CreateObject( "WinHttp.WinHttpRequest.5.1" )
  objHTTP.Open "GET", strURL
  objHTTP.Send

  ' Check if the result was valid, and if so return the result
  If objHTTP.Status = 200 Then strMyIP = objHTTP.ResponseText
  Set objHTTP = Nothing

  Set oNewMessage = CreateObject("hMailServer.Message")
  oNewMessage.From = "GetMyIP"
  oNewMessage.FromAddress = "[email protected]"
  'oNewMessage.ReplyTo = oNewMessage.FromAddress
  oNewMessage.Subject = strMyIP
  oNewMessage.AddRecipient oMessage.From, oMessage.FromAddress
  oNewMessage.Body = "http://" & strMyIP
  oNewMessage.Save
 
  set oNewMessage = Nothing     
 
End Function


Top
 Profile  
 
 Post subject: Re: Add text to body and forward email
PostPosted: 2012-03-02 22:51 
New user
New user

Joined: 2012-03-02 10:16
Posts: 4
Hi,

In addition you may want to test for a "password" in the sending field in the rules so not just anybody can request it :-)

Regards


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 


Who is online

Users browsing this forum: No registered users and 5 guests



Search for:
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group