Title: Re: Re setting from header field
On 6/11/01 8:39 PM, "Allen Watson" <[EMAIL PROTECTED]> wrote:
> Guys, I always enjoy reading how problems are solved with scripting. Here, I
> think Paul overlooked a couple of lines in David's early post. He said:
>
>> The first non blank line in the body of the email Entourage receives is the
>> original from header value.
>> For example the above email is actually from Chris MEARS.
>>
>> If the mail had originated external to my organization the first line would
>> have been of the form:
>>
>> <name> email address
>
> As I understand it, then, the example was from <internal> mail (where the
> name is enough). If the mail comes from an external source, the first line
> DOES include the E-mail address. In that case, Paul, a simple revision to
> your script would do the job, would it not?
Yes, I did miss that.
>
> Instead of this:
>
>
> set display name of sender of theMsg to nameLine
>
> you would have this:
>
> set rightBrackLoc to offset of ">" in nameLine
> set dn to text ((offset of "<" in nameLine) + 1) thru (rightBrackLoc -1) of
> nameLine
> set addr to text (rightBrackLoc + 1) thru -1 of nameLine
> set display name of sender of theMsg to dn
> set address of sender of theMsg to addr
>
> Yes? No?
>
Yes, but i hate 'offset' with a vengeance and never use it myself. Too many possibilities of mistakes (another instance of a ">" sign would muck this up.) Also, someone could be sending an email without using a display name. Then you don't usually get the "< >" sign at all. Although, sometimes you do, but there would be no spaces left, because I'd removed them. Also, TIDs are a lot faster (not that it matters here).
I would do (after all the other text parsing);
set AppleScript's text item delimiters to {"<"}
try
set dName to text item 1 of nameLine
try
set dName to text 1 thru –2 of dName
on error — no name, but < > around email addrtess
set dName to ""
end try
set eAddress to text item 2 of nameLine -- may error if no email address
set AppleScript's text item delimiters to {">"}
set eAddress to text item 1 of eAddress
on error
if nameLine contains "@" and nameLine does not contain " "
set dName to ""
set eAddress to nameLine
else
set dName to nameLine
set eAddress to address of sender of theMsg
end if
end try
set AppleScript's text item delimiters to {""}
set display name of sender of theMsg to dName
set address of sender of theMsg to eAddress
?
--
Paul Berkowitz
- Re setting from header field David Leitch
- Re: Re setting from header field Paul Berkowitz
- Re: Re setting from header field Paul Berkowitz
- Re: Re setting from header field David Leitch
- Re: Re setting from header field Paul Berkowitz
- Re: Re setting from header field David Leitch
- Re: Re setting from header field Allen Watson
- Re: Re setting from header field David Leitch
- Re: Re setting from header field Paul Berkowitz
- Re: Re setting from header field David Leitch
- Re: Re setting from header field Allen Watson
