Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Add Reply-To header for Distribution List
PostPosted: 2005-07-28 16:25 
New user
New user

Joined: 2005-07-27 05:16
Posts: 9
Location: Curitiba/PR/Brazil
For 4.1 or up versions only

Code:
Sub OnDeliverMessage(oMessage)
If InStr(oMessage.To, "distrlist@domain.com") Then
  oMessage.HeaderValue("Reply-To") = "distrlist@domain.com"
  oMessage.Save()
End If
End Sub


Top
 Profile  
 
 Post subject: Re: Add Reply-To header for Distribution List
PostPosted: 2006-07-24 15:31 
New user
New user

Joined: 2006-04-03 14:50
Posts: 20
Location: Sydney, Australia
And if you want to change the subject to show it was from a list you can do that easily too!

I added the "LCase()" conversion - is it needed?

Code:
Sub OnDeliverMessage(oMessage)
If InStr(LCase(oMessage.To), "distrlist@domain.com") Then
  oMessage.HeaderValue("Reply-To") = "distrlist@domain.com"
  If Not (InStr(lcase(oMessage.Subject), LCase("[List prefix]")) > 0) then
    oMessage.Subject = "[List prefix]" & oMessage.Subject
  end if
  oMessage.Save()
End If
End Sub


Peter

(edited later a couple of times)


Last edited by peter_mcc on 2006-08-01 11:37, edited 4 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: 2006-07-24 20:22 
Site Admin

Joined: 2005-07-29 16:18
Posts: 13628
Location: UK
Code:
If InStr(LCase(oMessage.To, "distrlist@domain.com") Then

You are missing a matching brace.
Code:
If InStr(LCase(oMessage.To, "distrlist@domain.com")) Then


-Jon


Top
 Profile  
 
 Post subject:
PostPosted: 2006-07-24 23:43 
New user
New user

Joined: 2006-04-03 14:50
Posts: 20
Location: Sydney, Australia
OOops. I actually meant to type

Code:
If InStr(LCase(oMessage.To), "distrlist@domain.com") Then


ie convert the "to" field to lower case before doing the check.

Peter


Top
 Profile  
 
 Post subject: Re: Add Reply-To header for Distribution List
PostPosted: 2008-04-16 18:45 
Normal user

Joined: 2008-04-16 18:35
Posts: 38
Instr has a case-insensitive compare. You can write it as such:

Code:
If InStr(1, oMessage.To, "distrlist@domain.com", vbTextCompare) Then


HOWEVER - as I discovered today, this can have unintended consequences if not watched carefully. If you have a user "jsmith@domain.com", and a list "smith@domain.com", it will incorrectly identify mail to "jsmith@domain.com" as being a list mail, because it contains the string "smith@domain.com".

There is no real perfect solution, but this is what I ended up using:

Code:
Sub OnDeliverMessage(oMessage)

  If IsMessageToList(oMessage, "list1@domain.com") Then
    oMessage.HeaderValue("Reply-To") = "list1@domain.com"
    oMessage.Save
  End If

  If IsMessageToList(oMessage, "list2@domain.com") Then
    oMessage.HeaderValue("Reply-To") = "list2@domain.com"
    oMessage.Save
  End If

End Sub

Function IsMessageToList(oMessage, sList)

  IsMessageToList = False
 
  If LCase(oMessage.To) = LCase(sList) Then IsMessageToList = True
  If LCase(oMessage.CC) = LCase(sList) Then IsMessageToList = True

  If InStr(1, oMessage.To, "<" & sList & ">", vbTextCompare) Then IsMessageToList = True
  If InStr(1, oMessage.CC, "<" & sList & ">", vbTextCompare) Then IsMessageToList = True
 
End Function


Top
 Profile  
 
 Post subject: Re: Add Reply-To header for Distribution List
PostPosted: 2009-01-24 18:51 
Normal user

Joined: 2008-01-18 21:00
Posts: 190
I have a script doing the same. But be aware if you have an email to more than one distribution list, this won't work. I duplicate the msg and change it for every recipient.


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 0 guests



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