Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yd-email
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xingmin
yd-email
Commits
82a0b89d
Commit
82a0b89d
authored
Sep 28, 2025
by
zhangxingmin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
push
parent
4be82047
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
4 deletions
+18
-4
yd-email-api/src/main/java/com/yd/email/api/service/impl/ApiEmailServiceImpl.java
+18
-4
No files found.
yd-email-api/src/main/java/com/yd/email/api/service/impl/ApiEmailServiceImpl.java
View file @
82a0b89d
...
...
@@ -134,7 +134,7 @@ public class ApiEmailServiceImpl implements ApiEmailService {
Multipart
multipart
=
new
MimeMultipart
();
multipart
.
addBodyPart
(
messageBodyPart
);
//
多附件处理逻辑(您之前添加的)
//
修改附件处理部分:
if
(
StringUtils
.
isNotBlank
(
dto
.
getAttachmentPath
()))
{
String
[]
attachmentPaths
=
dto
.
getAttachmentPath
().
split
(
";"
);
for
(
String
attachmentPath
:
attachmentPaths
)
{
...
...
@@ -142,13 +142,27 @@ public class ApiEmailServiceImpl implements ApiEmailService {
if
(
StringUtils
.
isNotBlank
(
attachmentPath
))
{
try
{
MimeBodyPart
attachmentPart
=
new
MimeBodyPart
();
DataSource
source
=
new
FileDataSource
(
attachmentPath
);
DataSource
source
;
String
fileName
;
if
(
attachmentPath
.
startsWith
(
"http://"
)
||
attachmentPath
.
startsWith
(
"https://"
))
{
// 使用URLDataSource处理网络附件
URL
url
=
new
URL
(
attachmentPath
);
source
=
new
URLDataSource
(
url
);
fileName
=
getFileNameFromUrl
(
attachmentPath
);
}
else
{
// 处理本地文件附件
source
=
new
FileDataSource
(
attachmentPath
);
fileName
=
new
File
(
attachmentPath
).
getName
();
}
attachmentPart
.
setDataHandler
(
new
DataHandler
(
source
));
attachmentPart
.
setFileName
(
new
File
(
attachmentPath
).
getName
()
);
attachmentPart
.
setFileName
(
fileName
);
multipart
.
addBodyPart
(
attachmentPart
);
log
.
info
(
"
成功
添加附件: {}"
,
attachmentPath
);
log
.
info
(
"添加附件: {}"
,
attachmentPath
);
}
catch
(
Exception
e
)
{
log
.
error
(
"添加附件失败: {}"
,
attachmentPath
,
e
);
throw
new
RuntimeException
(
"添加附件失败: "
+
attachmentPath
,
e
);
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment