Change entourage email address

We are in the process of changing our companies email addresses.

the old way is
new way is

I know how to fish the email address out of the default entourage account. How do change tell it to change _ to a . and drop the nyc.

Here is some code that takes a conservative approach to doing what you describe.

Addresses that do not end with “” are left untouched.
The only “nyc” that is dropped is the one between the at sign and “” at the end of the original address.
All remaining underscores are changed to dots. Domain names should not have underscores, but Microsoft software has been known to attempt such nonsense. If this is to be used in such an environment, extra care will have to be taken to change only underscores before the at sign.

to addressIsTargeted(inputAddr)
	return inputAddr ends with ""
end addressIsTargeted

to dropNYCFromCompanyDomain(inputAddr)
	-- Include the at sign and the full domain name to make sure we do not drop "nyc" in other parts of the email address.
	set targetString to ""
	set targetLength to length of targetString
	set keepPrefixLen to 1
	set keepSuffixLen to 11
	-- If we assume addressIsTargeted(inputAddr) would return true, then we could just say 
	-- tell inputAddr to return text 1 through -16 & text -11 through -1
	set targetOffset to offset of targetString in inputAddr
	if targetOffset is greater than 0 then
		-- Make sure target string match is at the end of the input string.
		log {targetOffset, targetLength, length of inputAddr}
		if targetOffset - 1 + targetLength is equal to length of inputAddr then
			-- Use the found offset, keep lengths, and target length to produce and return a new address with the undesirable part removed.
			tell inputAddr to return text 1 through (targetOffset - 1 + keepPrefixLen) & ¬
				text (targetOffset + targetLength - keepSuffixLen) through -1
			-- Return the original address if the target is not at the end.
			return inputAddr
		end if
		-- Return the original address if the target is not found.
		return inputAddr
	end if
end dropNYCFromCompanyDomain

-- A custom version of the code at
to changeUnderscoresToDots(inputAddr)
	set {oldTIDs, text item delimiters} to {text item delimiters, {"_"}}
	set inputAddr to text items of inputAddr
	set text item delimiters to {"."}
	tell inputAddr to beginning & ({""} & rest)
	set inputAddr to result
	set text item delimiters to oldTIDs
	return inputAddr
end changeUnderscoresToDots

to fixupAddress(inputAddr)
	if addressIsTargeted(inputAddr) then
		return result
	end if
	return inputAddr
end fixupAddress

set inputAddresses to {"", "", "", "", "", ""}
set newAddresses to {}
repeat with inputAddr in inputAddresses
	fixupAddress(contents of inputAddr)
	set end of newAddresses to result
end repeat


Model: iBook G4 933
AppleScript: 1.10.7
Browser: Safari 419.3
Operating System: Mac OS X (10.4)