You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Power Apps中使用5个附件控件发送邮件报错求助

问题分析与解决方案

错误原因

你当前的代码误用了ForAll函数的语法:ForAll仅接受一个数据源参数和对应的转换公式,不能直接传入多个附件集合及重复的转换块,这会导致语法解析错误。

正确实现方式

需要先将所有附件控件的Attachments集合合并为一个单一集合,再通过ForAll转换为SendEmailV2要求的附件格式。以下提供两种可行方案:

方案1:直接合并集合(简洁写法)

使用Power Apps的集合连接符&直接合并所有附件集合,无需临时变量:

Office365Outlook.SendEmailV2(
    "alan@c.com.hk",
    "Subject",
    "Body",
    {
        Attachments: ForAll(
            // 合并5个附件控件的所有附件
            Attachment_Inspection_Record.Attachments & 
            Attachment_CCM.Attachments & 
            Attachment_Sitephoto_1.Attachments & 
            Attachment_Sitephoto_2.Attachments & 
            Attachment_Sitephoto_3.Attachments,
            {
                ContentBytes: Value,
                Name: Name
            }
        )
    }
)

方案2:分步合并到临时集合(适合复杂场景)

如果后续需要对附件进行额外处理,可以先将所有附件收集到临时集合中,再进行转换:

// 清空并收集第一个控件的附件
ClearCollect(AllAttachments, Attachment_Inspection_Record.Attachments);
// 依次追加其他控件的附件
Collect(AllAttachments, Attachment_CCM.Attachments);
Collect(AllAttachments, Attachment_Sitephoto_1.Attachments);
Collect(AllAttachments, Attachment_Sitephoto_2.Attachments);
Collect(AllAttachments, Attachment_Sitephoto_3.Attachments);

// 发送邮件
Office365Outlook.SendEmailV2(
    "alan@c.com.hk",
    "Subject",
    "Body",
    {
        Attachments: ForAll(
            AllAttachments,
            {
                ContentBytes: Value,
                Name: Name
            }
        )
    }
)

额外注意事项

  • 确保每个附件控件的Allow multiple files属性已开启(若需要支持多附件上传)
  • 检查附件总大小是否符合Office 365的邮件附件限制(通常为35MB)

内容的提问来源于stack exchange,提问作者Alan Tse

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.15 16:11:10