Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 117 additions & 0 deletions connector_wechatemail_fdddf/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# 企业微信邮件连接器
企业微信邮件连接器 可连接企业微信邮件,可实现发送邮件、查询邮件列表及邮件内容等能力。

## 逻辑详情

### getAccessToken

获取access_token

入参:无
出参:String access_token

### getUnreadEmails

获取指定成员邮箱当前未读邮件数量

入参:EmailUnreadRequest request, String token
出参:EmailUnreadResponse

### readEmail

获取邮件内容 eml数据

入参:EmailReadRequest request, String token
出参:EmailReadResponse

### getInboxEmails

获取应用的收件箱邮件列表

入参:EmailListRequest request, String token
出参:EmailListResponse

### parseEml

解析eml邮件内容

入参:String emlContent
出参:ParsedEmail

#### ParsedEmail
```
subject: 主题
from: 发送人
toRecipients: 收件人 List<String>
sendDate: 发送时间
attachments: 附件列表 List<EmlAttachment>
```

#### EmlAttachment
```
fileName: 文件名
mimeType: 文件类型
content: base64编码的文件内容
```

示例:

```
ParsedEmail{subject='Re: 测试带附件邮件', from=xxxx@126.com', toRecipients=[youjianzhushou@xxxx.com], sentDate=2024-09-29, body='Thanks mike, I’m black

> On Sep 29, 2024, at 23:15, 邮件助手 <youjianzhushou@xxxx.com> wrote:
>
> 测试带附件邮件内容<20240928160103-Sqcf8q2k.jpg>

', attachments=[]}

```

### sendNormalEmail

发送普通邮件

入参:EmailRequest request, String token
出参:WeChatResponse

### sendMeetingEmail

发送会议邮件

入参:EmailMeetingRequest request, String token
出参:WeChatResponse

### sendScheduleEmail

发送日程邮件

入参:EmailScheduleRequest request, String token
出参:WeChatResponse


### getUserIdByMobile

根据手机号获取userid

入参:GetUserIdByMobileRequest request, String token
出参:GetUserIdResponse

### getUserIdByEmail

根据邮箱获取userid

入参:GetUserIdByEmailRequest request, String token
出参:GetUserIdResponse


## 使用步骤说明

1. 应用集成中导入连接器 “企业微信邮件连接器”
2. 添加连接器,填写参数 cropid、secret , 参考 https://developer.work.weixin.qq.com/document/10013
3. 逻辑调用示例截图



## 应用演示链接

[使用了本依赖库的制品应用链接]
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mvn install:install-file -Dfile="nasl-metadata-maven-plugin-1.3.0.jar" -DpomFile="pom.xml"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mvn install:install-file -Dfile="nasl-metadata-maven-plugin-1.3.0.jar" -DpomFile="pom.xml"
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.netease.lowcode</groupId>
<artifactId>nasl-metadata-maven-plugin</artifactId>
<version>1.3.0</version>
<packaging>maven-plugin</packaging>

<name>Nasl Metadata Maven Plugin</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
<version>2.0.10</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-manager</artifactId>
<version>2.8.4</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>3.0.8</version>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-common-artifact-filters</artifactId>
<version>3.0.1</version>
</dependency>

<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-aether-provider</artifactId>
<version>3.3.9</version>
</dependency>

<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-api</artifactId>
<version>1.1.0</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.2</version>
<configuration>
<goalPrefix>nasl-metadata-maven-plugin</goalPrefix>
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
</configuration>
</plugin>
</plugins>
</build>
</project>
105 changes: 105 additions & 0 deletions connector_wechatemail_fdddf/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.9.RELEASE</version><!--与当前制品应用默认版本统一-->
<relativePath/> <!-- lookup parent from repository -->
</parent>

<groupId>fdddf</groupId>
<artifactId>connector_wechatemail</artifactId>
<name>企业微信邮件连接器</name>
<description>企业微信邮件连接器</description>
<version>1.0.1</version>

<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<nasl.ide.version>3.3</nasl.ide.version>
</properties>
<dependencies>
<!--本案例是本地系统引入nasl-metadata-collector-0.8.0.jar的方式。
若把nasl-metadata-collector-0.8.0.jar安装到自己的maven仓库,
注意修改artifactId和groupId的情况下,不要使用<scope>system</scope>,会在发布时造成依赖中断。
不修改artifactId和groupId的情况下,nasl-metadata-maven-plugin会做特殊处理-->
<dependency>
<artifactId>nasl-metadata-collector</artifactId>
<groupId>com.netease.lowcode</groupId>
<version>0.8.0</version>
<optional>true</optional>
<scope>system</scope>
<systemPath>${project.basedir}/jar/nasl-metadata-collector-0.8.0.jar</systemPath>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>provided</scope>
<version>1.7.30</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.14.9</version>
</dependency>
<!-- http -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.14</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.16</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.5.14</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>2.0.53</version>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.netease.lowcode</groupId>
<artifactId>nasl-metadata-maven-plugin</artifactId>
<version>1.3.0</version>
<configuration>
<jarWithDependencies>false</jarWithDependencies>
</configuration>
<executions>
<execution>
<goals>
<goal>archive</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.fdddf.wechat;

import com.fdddf.wechat.email.EmailMeetingRequest;
import com.fdddf.wechat.email.EmailRequest;
import com.fdddf.wechat.email.EmailScheduleRequest;

public class Compose {
public final static String emailUrl = "https://qyapi.weixin.qq.com/cgi-bin/exmail/app/compose_send?access_token=";

/**
* 发送日程邮件
* @param request EmailScheduleRequest
* @param token 接口凭证
* @return
*/
public static WeChatResponse sendScheduleEmail(EmailScheduleRequest request, String token) {
String url = emailUrl + token;
return WeiXinUtil.request(url, token, request, WeChatResponse.class);
}

/**
* 发送会议邮件
* @param request EmailMeetingRequest
* @param token 接口凭证
* @return
*/
public static WeChatResponse sendMeetingEmail(EmailMeetingRequest request, String token) {
String url = emailUrl + token;
return WeiXinUtil.request(url, token, request, WeChatResponse.class);
}

/**
* 发送普通邮件,支持附件能力
* @param request EmailRequest
* @param token 接口凭证
* @return
*/
public static WeChatResponse sendNormalEmail(EmailRequest request, String token) {
String url = emailUrl + token;
request.organizeAttachment();
return WeiXinUtil.request(url, token, request, WeChatResponse.class);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.fdddf.wechat;

import com.fdddf.wechat.contact.GetUserIdByEmailRequest;
import com.fdddf.wechat.contact.GetUserIdByMobileRequest;
import com.fdddf.wechat.contact.GetUserIdResponse;

public class Contact {

/**
* 邮箱获取userid
* @param request GetUserIdByEmailRequest
* @param token String token
* @return
*/
public static GetUserIdResponse getUserIdByEmail(GetUserIdByEmailRequest request, String token) {
String url = "https://qyapi.weixin.qq.com/cgi-bin/user/get_userid_by_email?access_token=" + token;
return WeiXinUtil.request(url, token, request, GetUserIdResponse.class);
}

/**
* 手机号获取userid
* @param request GetUserIdByMobileRequest
* @param token String token
* @return
*/
public static GetUserIdResponse getUserIdByMobile(GetUserIdByMobileRequest request, String token) {
String url = "https://qyapi.weixin.qq.com/cgi-bin/user/getuserid?access_token=" + token;
return WeiXinUtil.request(url, token, request, GetUserIdResponse.class);
}

}
Loading