Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Exchange
2000.active.directory
2000.admin
2000.announcements
2000.app.conversion
2000.applications
2000.clients
2000.clustering
2000.connectivity
2000.development
2000.documentation
2000.general
2000.information.store
2000.interop
2000.kms
2000.misc
2000.protocols
2000.realtime.collabo.
2000.setup
2000.transport
2000.win2000
admin
application.conversion
applications
clients
clustering
connectivity
design
development
misc
mobility
setup
tools
  
 
date: Tue, 18 Mar 2008 02:52:00 -0700,    group: microsoft.public.exchange.development        back       


Exchange 2003 event sink to modify from adress doesn't work correc   
Hello,

I have an issue I can't explain to myself right now. I took a .vbs Script 
and registered it as an event sink in Exchange 2003 SP2 (SBS 2003) to modify 
the from address for a certain sender. 

It is working so far that the address is being replaced, but there ist an 
additional term saying "support1@something.de on behalf of 
support@something.de" in the address field.

So I guess Exchange is altering the message after the Event Sink. Why is 
that and how can I get around it?

The Script looks like this:

'<SCRIPT LANGUAGE="VBScript">
Option Explicit

'-------------------------------------------------------------------------
' FromModify.vbs
'
' Description: Modifies the "FROM" Address in the Header"
' Smaple to remove "DisplayName"
' Smaple to replace FROM-Address
'
' Runtime Errors are not handled
'
' (c)2006 Frank Carius. www.msxfaq.de
'
' Version 1.0 (14. Aug 2006) Frank Carius
'
' For information about this namespace, see
'   
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdosys/html/_cdosys_schema_smtpenvelope.asp
' For information about the CdoEventStatus enumeration, see
'   
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdosys/html/_cdosys_cdoeventstatus_enum.asp
' urn:schemas:mailheader: Namespace
' 
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdosys/html/dbca4fb9-afcb-4716-9e0c-4bff45ca0b60.asp'
' The Advanced Queuing engine
' 
http://www.microsoft.com/technet/prodtechnol/exchange/guides/E2k3TechRef/eaad59e4-ccbe-4ebf-ac14-69264b1cc167.mspx?mfr=true
'
' Does NOT Work for Messages qued by MAPI. Has to be SMTP, OWA, ActiveSync 
or use a second SMTP as relay
'-------------------------------------------------------------------------

Const CDO_RUN_NEXT_SINK = 0
Const logfile = "D:\FromModify.log"
Const Loglevel = 5

Sub ISMTPOnArrival_OnArrival(ByVal Msg, EventStatus)
'	On Error Resume Next
	Dim objFields, strFrom

	AppendLog "-- FromModify START -----", 4

	AppendLog "load Message Properties", 5
	AppendLog " msg.from    :" & msg.from, 5
	AppendLog " msg.to      :" & msg.to, 5
	AppendLog " msg.subject :" & msg.subject, 5
	
	AppendLog "---- Processing FROM -----", 4
	strFrom = msg.from
	AppendLog " FROM (original): " & strFrom  , 5

	' This line removes everything in front of the "<"-Character
	'strfrom = mid(strfrom,instr(strfrom,"<"))
	'AppendLog " FROM (StripDisplayname): " & strFrom  , 5

	' This part replaced the FROM Address in the Header
	if instr(lcase(strfrom),"support1@something.de")>0 then strfrom = 
"""Support"" "
	AppendLog " FROM (modified): " & strFrom , 5

	msg.from = strFrom	
	Msg.Datasource.Save  ' save changes to the mail

	AppendLog "-- FromModify END -----", 4
	EventStatus = CDO_RUN_NEXT_SINK
End Sub


Sub AppendLog(strLog, errlevel)
	'Add an entry to the protocol and debugging log file
	Dim file
	Dim fs

	if loglevel>=errlevel then
		Set fs = CreateObject("Scripting.FileSystemObject")
		Set file = fs.OpenTextFile(logfile, 8, true)
		file.Write(Now & ",")
		select case errlevel
			case 1	file.Write("Fatal Line" & err.Source)
			case 2	file.Write("Error")
			case 3	file.Write("Warning")
			case 4	file.Write("Information")
			case 5	file.Write("Debug")
			case else file.Write("Code:"&errlevel)
		end select
		file.WriteLine(","&strLog)
		file.Close
	end if
End Sub

'</SCRIPT>

Regards,

Phil
date: Tue, 18 Mar 2008 02:52:00 -0700   author:   Jan-Philipp Wagner

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us