Extract Email address from Sender?

I am trying to extract the domain from the email address of a sender of an email received in MS Entourage.

The code gets the full detail (i.e. {address:"nadda@middlebutler.info", display name:"AirlineTickets"} ) but I can not see a method of extracting the domain of the sender?

PRH
tell application "Microsoft Entourage"
	
	set theSelection to selection
	set theCurrentMessage to item 1 of theSelection
	sender of theCurrentMessage
		
end tell

Open in new window

PeterRHawkesAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

1209ylCommented:
Open up the email header and look for the very last IP address entry in it. The IP SHOULD be in [ ], so try the very last IP thats in [ ]. Once you get that IP, go to http://whois.domaintools.com/ . Once there, type in the IP address that you got and it should tell you what domain the email was sent from.
0
SimonCommented:
Hi, From your question, I understand you wish to extract the domain from the sender's address, which the code below will demonstrate. As posted, it returns the senders username and domain as a 2-element array. Change the last line to 'return senderDomain' if you only want the domain.

1209yl's post above describes a more forensic approach to determining the true originating domain. I'm not sure which you're interested in.

Simon
p.s. there is no built-in Applescript method in Entourage to get just the sender's domain, so it requires string manipulation as demonstrated in the code snippet.

tell application "Microsoft Entourage"
	
	set theSelection to selection
	set theCurrentMessage to item 1 of theSelection
	sender of theCurrentMessage
	log sender
	--headers of theCurrentMessage -- Get headers if you want to examine the IPs in the SMTP route.
	set theSenderAddress to address of sender of theCurrentMessage
	--Find the position of the "@" in the sender adddress
	set domainDelimiter to the offset of "@" in theSenderAddress
	set senderName to text 1 thru (domainDelimiter - 1) of theSenderAddress
	set senderDomain to text (domainDelimiter + 1) thru -1 of theSenderAddress
	return {senderName, senderDomain}
end tell

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Swift Programming

From novice to tech pro — start learning today.