Move message to Inbox (gmail / imap)

Hi all.

None of the following work. The message temporarily disappears from its mailbox and reappears when the synchronize command is sent. Is this a bug?

Thanks.

tell application "Mail"
	set myAccount to account "accountName"
	set myMessage to first item of (get selection)
	
	-- These don't work
	--move myMessage to inbox
	--move myMessage to mailbox "INBOX" of myAccount
	--set myMessage's mailbox to mailbox "INBOX" of myAccount
	
	synchronize with myAccount
end tell

What if you insert a delay between the move instruction and the synchronize one ?

Yvan KOENIG running El Capitan 10.11.4 in French (VALLAURIS, France) vendredi 29 avril 2016 20:40:09

HI Yvan,

The delay doesn’t work. The message disapears, delays, and reappears.

Hello

What moved originally the message out of the inbox ?
On my machine most of the messages received in my account xx@mac.com remain in the inbox.
Some are moved by rules.
If I move back them to the inbox, the rules return them to their predefined location.
Isn’t such a scheme at work on your machine ?

Yvan KOENIG running El Capitan 10.11.4 in French (VALLAURIS, France) samedi 30 avril 2016 09:58:26

I manually dragged the messages to the mailbox and there are no active rules moving messages.

Maybe it has something to do with this. This message is in a mailbox.

tell application "Mail" to set myMailbox to mailbox of first item of (get selection)

– mailbox “[Gmail]/All Mail” of account “accountName” of application “Mail”

I ran :

tell application "Mail"
	set myAccount to account "Yahoo"
	
	set myMessage to first item of (get selection)
	subject of myMessage
	set sourceBox to mailbox of myMessage
	-- These don't work
	--move myMessage to inbox
	move myMessage to mailbox "INBOX" of myAccount
	--set myMessage's mailbox to mailbox "INBOX" of myAccount
	tell me to delay 1
	synchronize with myAccount
	
	
	subject of every message of mailbox "INBOX" of myAccount
	subject of every message of sourceBox
end tell

I got this events log

tell application "Mail"
	get account "Yahoo"
		--> account "Yahoo"
	get selection
		--> {message id 154137 of mailbox "[Gmail]/Tous les messages" of account "Gmail"}
	get subject of message id 154137 of mailbox "[Gmail]/Tous les messages" of account "Gmail"
		--> "AppleScript"
	get mailbox of message id 154137 of mailbox "[Gmail]/Tous les messages" of account "Gmail"
		--> mailbox "[Gmail]/Tous les messages" of account "Gmail"
	move message id 154137 of mailbox "[Gmail]/Tous les messages" of account "Gmail" to mailbox "INBOX" of account "Yahoo"
	synchronize with account "Yahoo"
	get subject of every message of mailbox "INBOX" of account "Yahoo"
		--> {"Applescript"}
	get subject of every message of mailbox "[Gmail]/Tous les messages" of account "Gmail"
		--> {"[Flickr] Bienvenue !", "Applescript", "Contrôlez et sécurisez votre compte Google avec "Mon compte"", "Important notice"}
end tell

To be sure of the status of the mailboxes, I asked Mail to rebuild them.
When I looked at them, the message was in the INBOX of Yahoo and there was nothing in the original mailbox.
Some times after I discovered that the message was no longer in the INBOX of Yahoo and no more in the original box.

I entered the folder ~/Library/Mail and looked at the contents of the dedicated subfolders.
The files containing the message are no longer available.

No idea of what did that. Happily, the message wasn’t important.

Yvan KOENIG running El Capitan 10.11.4 in French (VALLAURIS, France) samedi 30 avril 2016 20:57:08

Absolutely foolish : this morning the message which seemed to be lost yesterdays is back.

Yvan KOENIG running El Capitan 10.11.4 in French (VALLAURIS, France) dimanche 1 mai 2016 15:39:39