• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Scripting Mail for Spam
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Scripting Mail for Spam


  • Subject: Scripting Mail for Spam
  • From: "S. J. Cunningham" <email@hidden>
  • Date: Mon, 30 Mar 2015 12:39:29 -0400

I am trying to write a spam filter for messages that have been getting by Mail's internal filter,  When I identify the message as spam I want to mark it as junk and move it to the junk mailbox.  You would think that all you have to do is set the "junk mail status" property of the message to true:

	-- SpamScan() is a handler I wrote that is part of the script invoked by the rule

	if my SpamScan(theSubject) is true then
		set read status of theMessage to true
		move theMessage to mailbox "Junk"  -- Note:  I also tried just "junk mailbox" and "mailbox junk mailbox", but they didn't work
		set junk mail status of theMessage to true
	end if

Doing that causes the attached error in the console log.  The message is moved to the Junk folder but the junk mail status is not changed.  (Note if you leave it in the original folder the junk mail bit is set but the console error is still thrown).

"theMessage" is "message ID xxx of mailbox yyy".  Figuring that the id property would be mailbox independent, I tried using the message's id to reference the message but couldn't find a way to do it.  For example

		set theID to the id of message theMessage
		--> xxx
		get id of message xxx
		--> "Mail got an error: Can’t get message xxx"  Go figure.  I thought id's were application universals.

Any Mail scripters out there who can help me out?

Thanks.



Attachment: Console Log Error Message:

3/30/15 6:03:33 AM	Mail[50190]	*** Assertion failure in +[Library flagsChangedForMessages:flags:oldFlagsByMessage:newFlagsByMessage:updateUnreadCount:], /SourceCache/Message/Message-1085/Library.subproj/Library.m:718
This method must be called off the main thread
(
	0   Message                             0x00007fff864e57b0 -[MFAssertionHandler _handleFailureWithPreamble:description:arguments:] + 137
	1   Message                             0x00007fff864e5715 -[MFAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 220
	2   Message                             0x00007fff863cb407 +[Library flagsChangedForMessages:flags:oldFlagsByMessage:newFlagsByMessage:updateUnreadCount:] + 192
	3   Message                             0x00007fff863cad28 -[MessageStore setFlagsFromDictionary:forMessages:] + 1275
	4   Message                             0x00007fff863ca695 -[MessageStore setJunkMailLevel:forMessages:trainJunkMailDatabase:userRecorded:] + 807
	5   Message                             0x00007fff864beaec -[Message(ScriptingSupport) setIsJunk:] + 115
	6   Foundation                          0x00007fff81ef86c1 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 434
	7   Foundation                          0x00007fff81fecd21 -[NSObject(NSScriptingInternal) _scriptingSetValue:forKey:] + 116
	8   Foundation                          0x00007fff82023a4c -[NSSetCommand performDefaultImplementation] + 364
	9   Foundation                          0x00007fff8201ff86 -[NSScriptingAppleEventHandler handleCommandEvent:withReplyEvent:] + 222
	10  Foundation                          0x00007fff81f170d6 -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] + 360
	11  Foundation                          0x00007fff81f16f06 _NSAppleEventManagerGenericHandler + 114
	12  AE                                  0x00007fff8a67e32b _Z20aeDispatchAppleEventPK6AEDescPS_jPh + 162
	13  AE                                  0x00007fff8a67e224 _ZL25dispatchEventAndSendReplyPK6AEDescPS_ + 32
	14  AE                                  0x00007fff8a67e12b aeProcessAppleEvent + 210
	15  HIToolbox                           0x00007fff84a14619 AEProcessAppleEvent + 48
	16  AppKit                              0x00007fff870af095 _DPSNextEvent + 1191
	17  AppKit                              0x00007fff870ae801 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 155
	18  AppKit                              0x00007fff8707468f -[NSApplication run] + 395
	19  AppKit                              0x00007fff8706d3b0 NSApplicationMain + 364
	20  Mail                                0x000000010000205c 0x0 + 4294975580
)
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden


  • Prev by Date: Re: Algorithms in Applescript
  • Next by Date: Re: Best way to script Excel 2016 from Python
  • Previous by thread: Re: Caffeinate Toast
  • Index(es):
    • Date
    • Thread