INNOV-AI

Innovation and Research from Réunion Island, France

Back   Home

Download mails from IMAP remote connection @ CONNECT - Connections @ MentDB Weak

> Start the server
> (or start the server for the first time (embedded mode - H2 Database))
> (or start the server for the first time (remote mode - MySQL 8 Database))
> Open the MentDB Weak Editor

Click on 'CONNECT' tab, open 'Mail', right click on 'demo_cm_imap' and select 'GEN > DOWNLOAD MAILS'

MQL INPUT
script create post "demo.file.imap.download" false 1 
  (param
  ;) 
  "Download mail through IMAP" 
{

	#Initialization;
    -> "[receive_dir]" "tmp";

	#Récupération des mails;
	json load "receive_state" (mail download imap [receive_dir]
		3 unread null false true
		"2018-01-01" null
		(mql {string matches [imap_from] ".*digest-noreply@quora.com.*";})
		(mql {string matches [imap_subject] ".*champ.*";})
		{cm get "demo_cm_imap"}
	);

	if (> (json select "receive_state" "/NbReceived") 0) {

		-> "[sub_receive_dir]" (json select "receive_state" "/Directory");

		json load "sub_receive_dir" (file dir_list [sub_receive_dir]);
		json parse_array "sub_receive_dir" "/" "[mail]" {

			if (string ends_with [mail] ".json") {

				json load "current_mail" (file load (concat [sub_receive_dir] "/" [mail]));

				log trace (json doc "current_mail");

			};
		
		};

	};

	json doc "receive_state";
	
	
} "Return nothing";
start: 2026-01-17   end: 2026-01-31   v_start: 400   v_end: