感谢各位专家!
直接读取当前 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 或其他选项。