|
分享源码
界面截图: |
- |
是否带模块: |
调用了模块 |
备注说明: |
- |
需要ssl,imap取件,论坛找了下,好像没有稳定
就找了c++的编译成dll,配合易语言就完美调用了
依赖这个库:https://www.example-code.com/vcpp/imap_ssl.asp
附上简单修改的代码(取指定发件人发来的验证马,正则取出,失败返回-1,没有返回0,找到返回1)
- // dllmain.cpp : 定义 DLL 应用程序的入口点。
- #include "include/CkImap.h"
- #include "include/CkMessageSet.h"
- #include "include/CkEmailBundle.h"
- #include "include/CkEmail.h"
- #include <iostream>
- #include <regex>
- using namespace std;
- extern "C" __declspec(dllexport) int findMail(const char* pU, const char* pP, char* pOut) {
- int ret = -1;
- // This example assumes the Chilkat API to have been previously unlocked.
- // See Global Unlock Sample for sample code.
- CkImap imap;
- // To use a secure TLS/SSL connection, set the Ssl property and the port:
- imap.put_Ssl(true);
- // The typical port for IMAP SSL is 993
- imap.put_Port(993);
- // Connect to an IMAP server.
- if (imap.Connect("imap-mail.outlook.com")) {
- if (imap.Login(pU, pP)) {
- if (imap.SelectMailbox("Inbox")) {
- bool fetchUids = true;
- // Get the message IDs of all the emails in the mailbox
- CkMessageSet* messageSet = imap.Search("FROM 【【【这里改成发件人】】】", fetchUids);
- if (imap.get_LastMethodSuccess()) {
- CkEmailBundle* bundle = imap.FetchBundle(*messageSet);
- if (imap.get_LastMethodSuccess()) {
- // Loop over the bundle and display the FROM and SUBJECT of each.
- int i = 0;
- int numEmails = bundle->get_MessageCount();
- ret = 0;
- for (int i = numEmails - 1; i >= 0; i--) {
- CkEmail* email = bundle->GetEmail(i);
- regex reg(">(\\d{8})<");
- cmatch match;
- if (regex_search(email->body(), match, reg)) {
- string str(match[1].first, match[1].second);
- //cout << str << endl;
- strcpy_s(pOut, 10, str.c_str());
- ret = 1;
- break;
- }
- delete email;
- }
- // Disconnect from the IMAP server.
- imap.Disconnect();
- delete bundle;
- }
- delete messageSet;
- }
- }
- }
- }
- return ret;
- }
复制代码
补充内容 (2021-9-2 01:32):
突然发现,这个库是收费的,只能试用30天…… |
评分
-
查看全部评分
|