资讯动态

【Azure Logic App】Workflow中使用 SMTP 发送邮件成功,但打开附件时报错文件已损坏

发布时间:2026/10/15 3:42:59 来源:尧图企业网站定制
问题描述在 Azure Logic Apps Standard 中可以通过 Azure Blob Storage Connector 获取文件内容再通过内置 SMTP Send Email Action 将文件作为邮件附件发送。但是在实际运行时候遇见了问题1 Logic App Workflow 本身能够运行2 SMTP 邮件能够成功发送3 邮件中也存在附件4 但下载并打开附件时提示文件损坏无法正常打开基于以上的情况应该如何解决问题呢问题解答在只使用SMTP Send_Email Action做一个简单复现实验发现邮件发送成功并且附件正常打开。随后检查 Logic App 中 Workflow配置发现实际配置中的 contentData 值包含了 { 和 }。使用相同形式可以复现问题邮件中的附件无法打开提示内容被破坏。因此该问题的错误点是SMTP Send_Email Action 的 contentData 参数中出现了额外的 { }修改后问题得到解决。错误的附件配置为1234567attachment: [{fileName:test.xlsm,contentData:{body(Get_blob_content)},contentType:xlsm}]正确的附件配置如下1234567attachment: [{fileName:test.xlsm,contentData:body(Get_blob_content),contentType:xlsm}]其中fileName 指定附件名称,contentData 使用 Get_blob_content Action 返回的文件内容,contentType 设置为 xlsm。附件一完整的Logic App workflow code如下{ definition: { $schema: https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#, contentVersion: 1.0.0.0, actions: { Get_blob_content_(V2): { type: ApiConnection, inputs: { host: { connection: { referenceName: xxxblob } }, method: get, path: /v2/datasets/{encodeURIComponent(encodeURIComponent(AccountNameFromSettings))}/files/{encodeURIComponent(encodeURIComponent(xxxxxx))}/content, queries: { inferContentType: true } }, runAfter: {}, metadata: { xxxxx: test.xlsm } }, Send_Email: { type: ServiceProvider, inputs: { parameters: { from: xxxxxemail.com, to: xxxxxemail.com, importance: Normal, attachment: [ { fileName: test.xlsm, contentData: body(Get_blob_content), contentType: xlsm } ] }, serviceProviderConfiguration: { connectionName: Smtp, operationId: sendEmail, serviceProviderId: /serviceProviders/Smtp } }, runAfter: { Get_blob_content: [ SUCCEEDED ] } } }, outputs: {}, triggers: { When_an_HTTP_request_is_received: { type: Request, kind: Http } } }, kind: Stateful }当在复杂的环境中面临问题格物之道需浊而静之徐清安以动之徐生。 云中恰是如此!

读完文章,也想定制专属网站?

尧图设计师 24 小时内与您沟通定制方案

免费获取报价 →
↑