為您自己的內容撰寫程式碼 code-content

在此頁面上:​瞭解如何在電子郵件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

在電子郵件Designer程式碼編輯器中使用個人化時,now()函式無法用於動態日期計算。

IMPORTANT
在電子郵件產生器的運算式語言中,now()函式​不受支援。 雖然now()可在歷程條件中使用,但無法用於電子郵件內容或程式碼編輯器。

可用的替代方案:

使用下列功能處理電子郵件個人化中的目前日期和時間:

  • getCurrentZonedDateTime() — 傳回目前日期和時間,並附上時區資訊。 這是now()的建議替代方案。

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

  • currentTimeInMillis() — 傳回目前時間(以Epoch毫秒為單位)。

    範例: {%= 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