using terms from application "Mail"
on perform mail action with messages theMessages
tell application "Mail"
repeat with eachMessage in theMessages
set thisContent to get content of eachMessage
my commands(thisContent)
end repeat
end tell
end perform mail action with messages
end using terms from
on commands(thisContent)
set tmpFolderText to "Macintosh Hd:tmp:1.txt"
try
set fileRef to open for access tmpFolderText with write permission
set eof fileRef to 0
write thisContent to fileRef
close access fileRef
on error
try
close access fileRef
display dialog "Failed to write to file." giving up after 5 with icon 0
end try
end try
--Error here
do shell script "cat /tmp/1.txt | grep [url=http://www.activationlink.com]www.activationlink.com[/url]"
set theResult to result
(*Returns the result
[url=http://www.activationlink.com/id/74jfJeo3kHenfus83jbdfsj388iosfd]www.activationlink.com/id/74jfJeo3kHenfus83jbdfsj388iosfd[/url]
but also returns [url=http://www.activationlink.com]www.activationlink.com[/url] which is not in the email but in the do shell script line
this means when I wget [url=http://www.activationlink.com/id/74jfJeo3kHenfus83jbdfsj388iosfdwww.activationlink.com]www.activationlink.com/id/74jfJeo3kHenfus83jbdfsj388iosfdwww.activationlink.com[/url] I get error
when i wget it should look like [url=http://www.activationlink.com/id/74jfJeo3kHenfus83jbdfsj388iosfd]www.activationlink.com/id/74jfJeo3kHenfus83jbdfsj388iosfd[/url]
reason for grep [url=http://www.activationlink.com]www.activationlink.com[/url] because activation links are unique to the user or everytime requested*)
do shell script " wget " & theResult
--error ends here
end commands
From the text you posted, this works fine for me.
Are you sure that there is not another line somewhere in the email that has www.activationlink.com
Because thats the only way grep would put it in.
There is nothing in your grep statement to do otherwise.
Also why writing the content out??
just use:
using terms from application "Mail"
on perform mail action with messages theMessages
tell application "Mail"
repeat with eachMessage in theMessages
set thisContent to get content of eachMessage
my commands(thisContent)
end repeat
end tell
end perform mail action with messages
end using terms from
on commands(thisContent)
set theResult to do shell script "echo " & quoted form of thisContent & " | grep [url=http://www.activationlink.com]www.activationlink.com[/url]"
do shell script " wget " & theResult
end commands