AppleScript : - link mail with contacts

  • Thread starter Jean Frédéric FARNY
  • Start date
J

Jean Frédéric FARNY

Hello,

I'm wondering if somebody has developped an AppleScript that links all the
mail to the contacts. After a total rebuild of the database, all the links
are dead..

Best regards,

JFF
 
B

Barry Wainwright

Hello,

I'm wondering if somebody has developped an AppleScript that links all the
mail to the contacts. After a total rebuild of the database, all the links
are dead..

Best regards,

JFF

It can be done, but it would be very slow!

Look at each message, find (if possible) the sender in the address book,
then link the two.

Do this for every folder.

An untested script:

tell application "Microsoft Entourage"
set theFolders to every folder -- the root level folders
repeat with aFolder in theFolders
my recurseFolders(aFolder)
end repeat
end tell


on recurseFolders(thisFolder)
tell application "Microsoft Entourage"
repeat with aMessage in (get every message of thisFolder)
set theContacts to find (get address of sender of aMessage)
if theContacts ‚ {} then
repeat with aContact in theContacts
link aContact to aMessage
end repeat
end if
end repeat
set newFolders to every folder of thisFolder -- any subfolders?
repeat with aFolder in newFolders
my recurseFolders(aFolder) -- recursive call to process all
lower levels
end repeat
end tell
end recurseFolders


Note: there is no error checking in this script, and it will only work on
POP accounts as it stands ­ is it enough?
 
J

Jean Frédéric FARNY

Le 8/06/04 12:45, dans BCEB5758.18B75%[email protected], « Barry
Wainwright » said:
It can be done, but it would be very slow!
I got 1000 contacts and approx. 40000 msgs ;>
Look at each message, find (if possible) the sender in the address book,
then link the two.

Do this for every folder.

An untested script:

tell application "Microsoft Entourage"
set theFolders to every folder -- the root level folders
repeat with aFolder in theFolders
my recurseFolders(aFolder)
end repeat
end tell


on recurseFolders(thisFolder)
tell application "Microsoft Entourage"
repeat with aMessage in (get every message of thisFolder)
set theContacts to find (get address of sender of aMessage)
if theContacts ‚ {} then
repeat with aContact in theContacts
link aContact to aMessage
end repeat
end if
end repeat
set newFolders to every folder of thisFolder -- any subfolders?
repeat with aFolder in newFolders
my recurseFolders(aFolder) -- recursive call to process all
lower levels
end repeat
end tell
end recurseFolders


Note: there is no error checking in this script, and it will only work on
POP accounts as it stands ­ is it enough?
Really great. Thanks a lot.. I'm gonna try this right now.

Best regads,

JFF
 
P

Paul Berkowitz

It can be done, but it would be very slow!

Look at each message, find (if possible) the sender in the address book, then
link the two.

Do this for every folder.

An untested script:

tell application "Microsoft Entourage"
set theFolders to every folder -- the root level folders
repeat with aFolder in theFolders
my recurseFolders(aFolder)
end repeat
end tell


on recurseFolders(thisFolder)
tell application "Microsoft Entourage"
repeat with aMessage in (get every message of thisFolder)
set theContacts to find (get address of sender of aMessage)
if theContacts ‚ {} then
repeat with aContact in theContacts
link aContact to aMessage
end repeat
end if
end repeat
set newFolders to every folder of thisFolder -- any subfolders?
repeat with aFolder in newFolders
my recurseFolders(aFolder) -- recursive call to process all lower
levels
end repeat
end tell
end recurseFolders


Note: there is no error checking in this script, and it will only work on POP
accounts as it stands ­ is it enough?


Another way to do it, quicker and easier, but which would lose the
"Received" time ("Sent" will still be OK) and the "Reply" links ("You
replied to this message on...") which maybe are already lost anyway(?) would
be to confirm that you have the "Link messages to senders" in Address Book
preferences, then drag out your mail folders to become .mbox files, delete
the original mail folders or - in the case of "special" folders like Inbox,
Sent Items, etc. delete the messages within. Then drag back or double-click
the MBOX files to re-import the messages. They'll all be linked to their
contacts. You'll then have to move messages from imported "inbox 1" folders
back into the real Inbox, etc. (Select all and use the Move button: it's
much better than dragging, for large numbers of messages). I think this will
work for IMAP messages too (maintaining links): you'll have to move messages
for all IMAP folders since the dragged-in MBOXes will have created local
folders. Then you can clean up by deleting empty local folders.

This will still be about 100 times quicker than waiting for the script to
finish. But that of course will work too.

--
Paul Berkowitz
MVP Entourage
Entourage FAQ Page: <http://www.entourage.mvps.org/faq/index.html>
AppleScripts for Entourage: <http://macscripter.net/scriptbuilders/>

Please "Reply To Newsgroup" to reply to this message. Emails will be
ignored.

PLEASE always state which version of Entourage you are using - **2004**, X
or 2001. It's often impossible to answer your questions otherwise.
 
J

Jean Frédéric FARNY

Le 8/06/04 16:52, dans BCEB20CE.67C83%berkowit@spoof_silcom.com, « Paul
Berkowitz » said:
Another way to do it, quicker and easier, but which would lose the
"Received" time ("Sent" will still be OK) and the "Reply" links ("You
replied to this message on...") which maybe are already lost anyway(?) would
be to confirm that you have the "Link messages to senders" in Address Book
preferences, then drag out your mail folders to become .mbox files, delete
the original mail folders or - in the case of "special" folders like Inbox,
Sent Items, etc. delete the messages within.
This sounds really fine ;)
Then drag back or double-click
the MBOX files to re-import the messages. They'll all be linked to their
contacts. You'll then have to move messages from imported "inbox 1" folders
back into the real Inbox, etc. (Select all and use the Move button: it's
much better than dragging, for large numbers of messages).
But sub-folders are not taken doing this way, so you have to dig to the
bottom and start from there.
I think this will
work for IMAP messages too (maintaining links): you'll have to move messages
for all IMAP folders since the dragged-in MBOXes will have created local
folders. Then you can clean up by deleting empty local folders.

This will still be about 100 times quicker than waiting for the script to
finish. But that of course will work too.
I might try to backup the database taking only message and try to reimport
the database.

Thanks a lot

JFF
 
P

Paul Berkowitz

But sub-folders are not taken doing this way, so you have to dig to the
bottom and start from there.

You have to drag out each subfolder separately, correct. Dragging out the
parent folder gets you only the messages in that parent folder, not the
subfolder structure. (How could that work? mbox files are just simple text
files - open one in TextEdit and see for yourself. There's no way to
replicate a folder hierarchy here.) That's not hard, it's easy. When you
drag back, drag the mboxes representing subfolder directly into their parent
folder (rather than double-clicking): they'll become subfolders again. If
you make a mistake and create them as top-level folders, simply drag them
into the parent folder and they'll immediately be subfolders. That takes
only an instant.
I might try to backup the database taking only message and try to reimport
the database.

No, that won't work. Entourage 2004 cannot "import" another 2004 identity.


--
Paul Berkowitz
MVP Entourage
Entourage FAQ Page: <http://www.entourage.mvps.org/faq/index.html>
AppleScripts for Entourage: <http://macscripter.net/scriptbuilders/>

Please "Reply To Newsgroup" to reply to this message. Emails will be
ignored.

PLEASE always state which version of Entourage you are using - **2004**, X
or 2001. It's often impossible to answer your questions otherwise.
 
Top