Script sometimes move wrong mail content to DT ...
OSX - El Capitan 10.11.6 & macOS Sierra 10.12.6:
I wrote a small Applescript which is invoked thru an special subject in incoming mails (mail rules).
This script should store the mail(subject, content etc.) into a subfolder of an special DT database and move it then into a subfolder in mail.
Usually the script is running fine an worked as expected.
But sometimes it stores NOT the original mail but the next incoming mail (with different mail-subject,-content etc.)into DT and sometimes nothing is stored in DT.
Sometimes the correct mail is then moved to a subfolder, but sometimes nothing happens (mail remain in the input folder).
I've tried several times to debug the problem, but actually I can not postpone the situtation.
Here is the code:
property pNoSubjectString : "(no subject)"
property nameDatabase : "~/Documents/DMS/MyDatabase.dtBase2"
property nameGroup : "/Office/Subfolder1/„
property nameDestinationMailbox : „Subfolder2“
property nameDestinationMailboxMail : „Folder/SubFolder“
using terms from application "Mail"
on perform mail action with messages theSelectedMessages for rule theRule
tell application "Mail"
repeat with theMessage in theSelectedMessages
set theAccount to name of account of mailbox of theMessage
tell theMessage
set {theDateReceived, theDateSent, theSender, theSubject, theSource, theReadFlag} to {the date received, the date sent, the sender, the subject, the source, the read status}
end tell
if theSubject is equal to "" then
set theSubject to pNoSubjectString
end if
tell application id "DNtp"
try
set theDatabase to open database nameDatabase -- Ensure that the database is open
set theGroup to create location nameGroup & nameDestinationMailbox in theDatabase
set existingEntries to search theSubject & ".eml" in theGroup
set existingRecordNumber to count of existingEntries
if ((count of existingEntries) = 0) then
create record with {name:theSubject & ".eml", type:unknown, creation date:theDateSent, modification date:theDateReceived, URL:theSender, source:(theSource as string), unread:(not theReadFlag)} in theGroup
end if
on error error_message number error_number
if error_number is not -128 then display alert "Mail" message error_message as warning
end try
end tell
-- now move the message into another mail subfolder
move theMessage to mailbox nameDestinationMailboxMail of account theAccount -- a folder contained by another folder
end repeat
end tell
end perform mail action with messages
end using terms from
I have already asked this question in the DT forum. But there you couldn´t find an error in the coding and recommended to me to turn to this forum here.
Any help is appreciated.
最后更新:2017-08-24 23:35:30
上一篇:
10 second delay after pressing power button
下一篇:
How to archive mail in Sierra
how to dismiss or close family sharing ! URGENT...
iOS 11.0.1 iPad the dock auto hide home screen!
2015 iMac 27 inch Thin Pink Vertical line on Sc...
How to share iCloud storage plan to family memb...
Logic Pro X hanging on bounce
Can you guys check my iphone storage capacity S...
Apple watch display problems
Where can I find MacOS Sierra to reinstall?
play iTunes playlists through Sonos system?
Icloud icon missing om iPad
相关内容
"com.apple.installer.pagecontroller error
any idea what error 3503 is?
Underallocation Detected on Main device
The operation couldn’t be completed. (BKA...
is ctoid.exe a virus on my ipad safari browser?
iTunes Error: Declined to authorize this image ...
Keep High Efficiency Original if Available Chec...
iTunes 12.7 cannot edit playlist
High Sierra Stuck & Decryption paused
Need to unlock iphone 5 to reactivate the phone...
热门内容
Christian Music Removed From Itunes
I'm being billed twice every month for Apple Mu...
iMac running slow
Fix disappearing album art after moving iTunes
Activation Locked iWatch
Can I change the iwatch to miles instead of kil...
I keep seeing the "You don't have permission to...
can't read any menus macbook air
iPad 2, iOs9.3, taking days to restore
charges made under itune memeberships