感謝各位專家!
直接讀取目前 JMP 表:
第 1 行包含寄件者電子郵件訊息
第 2 行包含收件者電子郵件訊息
收到電子郵件後,直接將收到的內容寫入目前表格「內容」欄位的第 2 行。
dt = New Table(
"EmailConfig",
Add Rows(2),
New Column("Email", Character, Set Values({
"A@gmail.com",
"B@gmail.com"
})),
New Column("Password", Character, Set Values({
"AA",
"BB"
})),
New Column("Content", Character, Set Values({
"Test",
""
}))
);
對 Python 來說,這裡不是提問的合適地方。
對於 JSL,你們提供的是什麼類型的服務?你們是否擁有 JMP 可以存取的用於發送和接收電子郵件的 API?
感謝各位專家!
人工智慧
這行不通。
dt = Current Data Table();
sender = Char(dt:Email[1]);
pwd_sender = Char(dt:Password[1]);
content = Char(dt:Content[1]);
receiver = Char(dt:Email[2]);
pwd_receiver = Char(dt:Password[2]);
proxy = "--proxy \!"http://127.0.0.1:7897\!"";
message_file = "C:\temp\jmp_message.txt";
Save Text File(message_file, "Subject: Test Email\n\n" || content);
send_options = {"smtp://smtp.gmail.com:587", "--mail-from", sender, "--mail-rcpt", receiver, "--user", sender || ":" || pwd_sender, "-T", message_file, "--ssl-reqd", proxy};
rp_send = Run Program(
Executable("curl.exe"),
Options(send_options),
ReadFunction(Function({this}, send_out = this << Read; Show(send_out); ))
);
Wait(10);
search_options = {"--url", "imaps://imap.gmail.com/INBOX", "--user", receiver || ":" || pwd_receiver, "-X", "\!"SEARCH ALL\!"", proxy};
rp_search = Run Program(
Executable("curl.exe"),
Options(search_options),
ReadFunction(Function({this}, search_out = this << Read; ))
);
match_pos = Contains(search_out, "* SEARCH");
if(match_pos > 0,
ids_start = match_pos + Length("* SEARCH ");
ids_end = Contains(search_out, "\r\n", ids_start);
ids = Substr(search_out, ids_start, ids_end - ids_start);
,
ids = "";
);
id_list = Words(ids, " ");
if(N Items(id_list) > 0,
last_id = id_list[N Items(id_list)];
,
last_id = "";
dt:Content[2] = "Receive Failed";
throw();
);
fetch_options = {"--url", "imaps://imap.gmail.com/INBOX", "--user", receiver || ":" || pwd_receiver, "-X", "\!"FETCH " || last_id || " BODY.PEEK[TEXT]\!"", proxy};
rp_fetch = Run Program(
Executable("curl.exe"),
Options(fetch_options),
ReadFunction(Function({this}, fetch_out = this << Read; ))
);
body_start = Contains(fetch_out, "{");
body_end = Contains(fetch_out, ")", body_start);
body_length = Num(Substr(fetch_out, body_start + 1, body_end - body_start - 1));
content_start = body_end + 2;
received_content = Substr(fetch_out, content_start, body_length);
cleaned = Trim(Regex(received_content, "[\\r\\n]+", " ", "GLOBALREPLACE"));
dt:Content[2] = cleaned;
我無法直接幫助你,但你可以使用 VScript 透過 JMP 發送郵件,使用 Mail() 命令,使用 PowerShell 透過 Send-MailMessage 或其他選項。