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

如何在Foundry TypeScript邮件通知函数中移除跳转至Foundry的蓝色链接框

如何在Foundry TypeScript邮件通知函数中移除跳转至Foundry的蓝色链接框

嘿,我来帮你搞定这个问题!那个烦人的蓝色跳转框其实是Foundry默认邮件通知模板自带的——它默认会给邮件加一个关联到Foundry内部通知的跳转区域。要去掉它,你只需要自定义邮件内容,完全绕过默认模板就行,具体操作看下面:

核心思路

Foundry的ShortNotification会自动生成带跳转框的默认邮件模板,所以咱们不用它来生成邮件内容,转而手动构建EmailNotificationContent,这样就能完全控制邮件里的每一个元素,不会出现那个蓝色框。

修改后的代码示例

把你原来的代码里的邮件生成部分替换成下面的逻辑就行:

import { Function, Notification, EmailNotificationContent, ShortNotification, User } from "@foundry/functions-api";
import { ExampleDataSource } from "@foundry/ontology-api";

export class notification_email { 
    @Function()
    public async createfsiNotification(exampleDataSource: ExampleDataSource, user: User): Promise<Notification> {
        // 保留这个短通知,用于Foundry内部的通知中心展示(可选,如果不需要也可以去掉)
        const shortNotification = ShortNotification.builder()
            .heading("New Update")
            .content("New content is ready for you")
            .build();

        // 自定义邮件内容,这里完全由你控制,不会自动生成蓝色跳转框
        const emailContent = EmailNotificationContent.builder()
            .subject("Your Custom Foundry Notification")
            // 纯文本版本(给不支持HTML的邮箱)
            .textBody(`Hi ${user.displayName},

New content has been added in Foundry.

Best regards,
Your Team`)
            // HTML版本,你可以随便写样式和内容
            .htmlBody(`
                <div style="font-family: 'Segoe UI', Arial, sans-serif; max-width: 600px; margin: 0 auto; padding: 20px;">
                    <h2 style="color: #2c3e50;">New Update Available</h2>
                    <p>Hi ${user.displayName},</p>
                    <p>We've added new content that requires your attention.</p>
                    <!-- 这里可以添加你自己的链接,比如直接跳转到特定的Foundry对象页面,或者什么都不加 -->
                    <p>Thanks,</p>
                    <p>Your Foundry Team</p>
                </div>
            `)
            .build();

        // 组装最终的通知,同时包含内部短通知和自定义邮件
        return Notification.builder()
            .shortNotification(shortNotification)
            .emailContent(emailContent)
            .recipient(user)
            .build();
    }
}

关键说明

  • 原来的代码里应该是依赖ShortNotification自动生成邮件,现在换成手动写EmailNotificationContent后,就不会有那个默认的蓝色跳转框了。
  • 你可以根据需求完全自定义HTML内容,包括样式、文字、链接(如果需要的话),完全不受默认模板限制。
  • 如果你不需要Foundry内部的通知中心提示,也可以去掉shortNotification相关的代码,只保留邮件内容部分。

备注:内容来源于stack exchange,提问作者Ashley Albright

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.17 09:33:09