对您自己的内容进行编码 code-content

在此页面上:​了解如何在Email Designer代码编辑器中编写或粘贴原始HTML以生成电子邮件内容,包括如何添加个性化设置以及可用的日期和时间函数。

自己编写代码​允许您编写或粘贴原始HTML,以直接在Journey Optimizer电子邮件Designer中生成电子邮件内容。 在需要完全控制标记或导入现有HTML时,请使用此模式。

您必须具备HTML技能,一旦选择此模式,您就停留在代码编辑器中 — 无法切换到可视编辑器。

➡️ 通过观看视频了解此功能

NOTE
您自己的代码​与电子邮件Designer中的高级HTML编辑器不同。 通过高级HTML编辑器,您可以随时在HTML视图和可视(桌面)视图(而不是代码编辑器)之间进行切换。 了解有关高级HTML编辑器的更多信息

使用代码编辑器 use-code-editor

要使用代码编辑器创建或编辑电子邮件内容,请执行以下步骤。

  1. 电子邮件Designer主页中,选择​自己编写代码

  2. 输入或粘贴您的原始 HTML 代码。

  3. 使用左窗格利用Journey Optimizer个性化功能。 了解详情

    note
    NOTE
    与旅程表达式相比,电子邮件Designer中的个性化编辑器存在一些功能限制。 了解有关日期/时间函数限制的更多信息
  4. 如果要清除电子邮件内容并从新的设计编写电子邮件内容,请从选项菜单中选择​更改您的设计

    note
    NOTE
    此操作将在电子邮件设计器中打开选定的模板。 您可以在其中完成电子邮件的设计,或使用​ 切换到代码编辑器 ​选项来返回代码编辑器。
  5. 单击​ 预览 ​按钮以使用测试用户档案检查邮件设计和个性化。 了解详情

  6. 在代码就绪后,单击​保存,然后返回消息创建屏幕以完成消息。

CAUTION
使用您自己的代码方法时,无法引用Adobe Experience Manager Assets中的图像。 将HTML代码中引用的图像存储到公共位置。

日期和时间函数限制 date-time-limitations

在Email Designer代码编辑器中使用个性化设置时,now()函数不可用于动态日期计算。

IMPORTANT
在电子邮件生成器的表达式语言中,now()函数是​不支持。 虽然now()在历程条件中可用,但它不能在电子邮件内容或代码编辑器中使用。

可用替代项:

使用以下功能处理电子邮件个性化中的当前日期和时间:

  • getCurrentZonedDateTime() — 返回包含时区信息的当前日期和时间。 这是now()的推荐替代方案。

    示例: {%= getCurrentZonedDateTime() %}返回2024-12-06T17:22:02.281067+05:30[Asia/Kolkata]

  • currentTimeInMillis() — 返回当前时间(以纪元毫秒为单位)。

    示例: {%= currentTimeInMillis() %}

建议的解决方法:

如果需要在电子邮件内容中执行日期计算:

  • 预先计算日期字段 — 在发送电子邮件之前,计算数据管道或配置文件属性中所需的日期值,然后在个性化设置中引用这些预先计算的值。

    示例: {%= profile.timeSeriesEvents._mobile.hotelBookingDetails.bookingDate %}

  • 使用日期操作函数 — 使用配置文件属性中日期值的日期/时间函数(如dayOfYear()diffInDays())。

    示例: {%= formatDate(profile.timeSeriesEvents._mobile.hotelBookingDetails.bookingDate, "MM/dd/YY") %}

  • 使用计算属性 — 创建执行复杂日期计算的计算属性,使结果可用作配置文件属性。

有关支持的函数的完整列表,请参阅日期和时间函数

AI Knowledge Reference

This section contains structured knowledge intended to support interpretation, retrieval, and question answering related to this topic.

For complete understanding, this information should be combined with the documentation on this page. Neither source is intended to stand alone; the page describes the feature, while this section provides additional context that helps disambiguate terminology, intent, applicability, and constraints.

  • TL;DR: This page explains how to use the Code your own mode to write or paste raw HTML in the Email Designer code editor to build email content, add personalization, and work with date and time using the available functions and workarounds.

Intents:

  • Write or paste raw HTML to build email content using Code your own
  • Add personalization using the left pane of the code editor
  • Preview the message design and personalization using test profiles
  • Clear content and start a new design with Change your design
  • Work with current date and time using available functions and recommended workarounds

Glossary:

  • Code your own: A mode to write or paste raw HTML to build email content directly in the Email Designer; once chosen, you stay in the code editor and cannot switch to the visual editor (product-specific)
  • Advanced HTML editor: A different feature that lets you toggle between HTML view and the visual (Desktop) view at any time; not the same as Code your own (product-specific)
  • getCurrentZonedDateTime(): Returns the current date and time with time zone information; the recommended alternative to now() (product-specific)
  • currentTimeInMillis(): Returns current time in epoch milliseconds (product-specific)

Guardrails:

  • You must have HTML skills; once you choose Code your own, you stay in the code editor and cannot switch to the visual editor.
  • The now() function is not supported in the Email Builder’s expression language; while available in journey conditions, it cannot be used within email content or the code editor.
  • The personalization editor in the Email Designer has some function limitations compared to journey expressions.
  • Images from Adobe Experience Manager Assets cannot be referenced when using Code your own; store referenced images in a public location.

Terminology:

  • Canonical name: Code your own — Acronym: n/a — variants: code editor, code your own content
  • Synonyms: “Code your own” = “code editor mode”
  • Do not confuse: “Code your own” (code editor only, no switch to visual editor) ≠ “advanced HTML editor” (toggles between HTML view and visual Desktop view)

FAQ:

  • Q: Can I switch from the code editor to the visual editor? — No; once you choose Code your own, you stay in the code editor. (The separate advanced HTML editor does allow toggling between HTML and Desktop views.)
  • Q: Can I use now() in email content or the code editor? — No; now() is not supported in the Email Builder’s expression language, though it is available in journey conditions. Use getCurrentZonedDateTime() (recommended) or currentTimeInMillis().
  • Q: Can I reference AEM Assets images in Code your own? — No; store images referenced in your HTML code in a public location.
  • Q: How can I perform date calculations in email content? — Pre-calculate date fields in your data pipeline or profile attributes, use date manipulation functions with profile date values, or use computed attributes.
recommendation-more-help
journey-optimizer-help