---
title: "ウォークスルー:カスタムメッセージテンプレートの作成"
slug: "walkthrough--building-a-custom-message-template"
abstract: "Email Experience Manager(EXM)でメールキャンペーンに使えるカスタムメッセージテンプレートの作り方。"
---
# ウォークスルー:カスタムメッセージテンプレートの作成

コンテンツエディターでは、Email Experience Manager(EXM)でメールキャンペーン用のカスタムメッセージテンプレートを作成できます。カスタムメッセージテンプレートを作成するには、ブランチテンプレート、メッセージテンプレート、レイアウトを作成し、それらを結合します。

> !注始める前に、カスタムメッセージテンプレートのレイアウトとして使いたいHTMLコードが手元にあることを確認してください。

このウォークスルーでは、以下の方法を説明します:

-   [分岐テンプレートを作成する](https://doc.sitecore.com/xp/ja/developers/exm/91/email-experience-manager/walkthrough--building-a-custom-message-template.html#UUID-b09a53c2-61e5-0b2c-a5b4-98c9efcbda25_N1529485804937 "Create a branch template")
-   [メッセージテンプレートを作成する](https://doc.sitecore.com/xp/ja/developers/exm/91/email-experience-manager/walkthrough--building-a-custom-message-template.html#UUID-b09a53c2-61e5-0b2c-a5b4-98c9efcbda25_N1529485820703 "Create a message template")
-   [レイアウトを作成する](https://doc.sitecore.com/xp/ja/developers/exm/91/email-experience-manager/walkthrough--building-a-custom-message-template.html#UUID-b09a53c2-61e5-0b2c-a5b4-98c9efcbda25_N1529485834960 "Create the layout")
-   [レイアウトとメッセージテンプレートをバインドします](https://doc.sitecore.com/xp/ja/developers/exm/91/email-experience-manager/walkthrough--building-a-custom-message-template.html#UUID-b09a53c2-61e5-0b2c-a5b4-98c9efcbda25_N1529485846452 "Bind the layout and the message template")
-   [テンプレートをEXMで利用可能にしてください](https://doc.sitecore.com/xp/ja/developers/exm/91/email-experience-manager/walkthrough--building-a-custom-message-template.html#UUID-b09a53c2-61e5-0b2c-a5b4-98c9efcbda25_N1529485860273 "Make your template available in EXM")
-   [条件フィルターにカスタムテンプレートを含める](https://doc.sitecore.com/xp/ja/developers/exm/91/email-experience-manager/walkthrough--building-a-custom-message-template.html#UUID-b09a53c2-61e5-0b2c-a5b4-98c9efcbda25_N1529485860273 "Make your template available in EXM")

## 分岐テンプレートを作成する

カスタムメッセージテンプレートは、ブランチテンプレートの定義アイテムと$nameアイテムからなるブランチデータテンプレートに基づいています。

ブランチテンプレートを作成するには:

1.  コンテンツエディターの*Messages*フォルダ(Templates/Branches/System/Email/Messages)に新しい分岐フォルダを挿入します。例えば*Custom newsletter*、そして**OK**をクリックします。
    
2.  分岐フォルダで新しい分岐を挿入し、「 **新しい分岐を作成する** 」ダイアログボックスでSystem/Branches/Branchに移動し、そこから **「作成**」をクリックします。
    
    ![Create\_a\_new\_branch.png](https://doc.sitecore.com/api/markdown-image/xp/ja/developers/exm/91/email-experience-manager/images/Create_a_new_branch.png)
    
3.  例えば、支部の名前を **「月刊ニュースレター**」に変更し、「 **コンテンツ** 」タブでアイコンをクリックして変更してください。このアイコンは、ユーザーがEXMで新しいメールキャンペーンを作成する際にメッセージテンプレートとして使われます。
    
4.  メッセージテンプレートに基づくメールキャンペーンでABテストを行うには、*$name*項目が*AB Testable Message*テンプレートに基づいていなければなりません。ツリーで *$name*アイテムをクリックし、リボンの「 **構成** 」タブをクリックし、**テンプレートグループで** 「 **変更**」をクリックします。
    
    ![The Change button on the Configure tab](<https://doc.sitecore.com/api/markdown-image/xp/ja/developers/exm/91/email-experience-manager/images/Building%20custom%20msg%20template%2090+.png>)
    
5.  テンプレート **選択** ダイアログボックスでTemplates/System/Email/Messages/AB Testable Messageに移動し、「 **次へ**」をクリックします。
    
    ![Select\_a\_templates.png](https://doc.sitecore.com/api/markdown-image/xp/ja/developers/exm/91/email-experience-manager/images/Select_a_templates.png)
    
6.  「 **次へ** 」をクリックして変更を確認し、その後 **「閉じる**」をクリックしてください。
    
7.  メッセージテンプレートをコンテンツレイアウトにバインドするには、*$name*項目の下にメッセージルートを挿入する必要があります。 *$name*項目を右クリックして「**Insert** , **Insert from template**」を選択してください。
    
8.  テンプレート**から挿入**ダイアログボックスで、Templates/System/Email/Messages/ Inner Content/Message Rootに移動し、**アイテム名**フィールドで名前を入力してください。例えば*Message root*、**をクリック。**
    
    ![Insert\_from\_template.png](https://doc.sitecore.com/api/markdown-image/xp/ja/developers/exm/91/email-experience-manager/images/Insert_from_template.png)
    
9.  メッセージのルートと *$name*アイテムをつなげるには、*$name*アイテムをクリックし、**メッセージ** セクションの**Body**欄でドロップダウン矢印をクリックしてメッセージのルートへ移動してください。
    
    ![Message.png](https://doc.sitecore.com/api/markdown-image/xp/ja/developers/exm/91/email-experience-manager/images/Message.png)
    

新しい分店テンプレートは以下のようになります:

![branch.png](https://doc.sitecore.com/api/markdown-image/xp/ja/developers/exm/91/email-experience-manager/images/branch.png)

## メッセージテンプレートを作成する

新しいテンプレートを作成して、デフォルトメッセージ内容として使いたい標準値を指定します。例えばヘッダーやフッターのテキストなどです。

テンプレートを作成するには:

1.  コンテンツエディターで /Templates/System/Email/Messages/Inner Contentに移動し、新しいテンプレートフォルダ(例えば*Custom newsletter*)を挿入します。 **OK**をクリックします。
    
2.  テンプレートフォルダ内に新しいテンプレートを挿入します。例えば、*カスタムニュースレターコンテンツ*などです。
    
    ![Select\_name.png](https://doc.sitecore.com/api/markdown-image/xp/ja/developers/exm/91/email-experience-manager/images/Select_name.png)
    
3.  新しいテンプレートでは「 **ビルダー** 」タブをクリックし、「 **新しいセクションを追加** 」フィールドで関連データテンプレートフィールド(例えばヘッダーテキストやフッターテキスト)を追加してください。
    
    ![Builder.png](https://doc.sitecore.com/api/markdown-image/xp/ja/developers/exm/91/email-experience-manager/images/Builder.png)
    
4.  変更を保存してください。
    

## レイアウトを作成する

メッセージテンプレートのレイアウトを作成するには:

1.  コンテンツエディターで /sitecore/Layout/Layouts/System/Email/ に移動し、新しいレイアウトを挿入します。例えば*Monthly Newsletter*。
    
    ![Content\_editor\_-\_monthly\_newsletter.png](https://doc.sitecore.com/api/markdown-image/xp/ja/developers/exm/91/email-experience-manager/images/Content_editor_-_monthly_newsletter.png)
    
2.  コンテンツツリーで新しいレイアウトを選択し、**コンテンツ** タブの **データ** セクションで **パス** フィールドをクリックして、レイアウトファイルが保存されている場所(例: /sitecore modules/web/exm/layouts/Two Column Layout.aspx)に移動します。
    
3.  Sitecoreインストールのwebrootファイル構造で、新しいレイアウトファイルを置いた場所に移動してください。例えば /Website/layouts/EmailCampaign/Sitecore Newsletter。
    
4.  該当するファイルを開き、レイアウトに使いたいカスタムHTMLコードを挿入します。
    
    例えば、ニュースレターのレイアウトの場合:
    
    <%@ Register TagPrefix="sc" Namespace="Sitecore.Web.UI.WebControls"
    Assembly="Sitecore.Kernel" %>
    <%@ Register TagPrefix="sc" Namespace="Sitecore.Web.UI.WebControls"
    Assembly="Sitecore.Analytics" %>
    <%@ OutputCache Location="None" VaryByParam="none" %>
    <html>
     <head>
     <title>
    <!-- Used for storing title of the email -->
    <sc:Placeholder Key="mn-title" runat="server" />
     </title>
    <!-- The VisitorIdentification control ensures that people viewing this page with a traditional web browser will be classified as humans not bots. This control is not required if people only view messages using Email clients -->
    <sc:VisitorIdentification runat="server" />
    </head>
    <body style="background-color:#1C1C1C">
    <form method="post" runat="server" id="mainform">
    <table width="100%">
    <tr>
    <td width="100%" colspan="2" style="background-color:#1C1C1C;color:#FFFFFF">
    
    <!-- Used for storing the title of the newsletter in h1 -->
    <sc:Placeholder runat="server" Key="mn-header" />
    </td>
    </tr>
    <tr>
    <td width="100%" style="background-color:#E6E6E6;color:#00000">
    <!-- Used for storing the content blocks of the newsletter in h2 and paragraphs -->
    <sc:Placeholder runat="server" Key="mn-content" />
    </td>
    </tr>
    <tr>
    <td width="100%" colspan="2" style="background-color:#1C1C1C;color:#FFFFFF">
    <!-- Used for storing the footer e.g. the unsubscribe link -->
    <sc:Placeholder runat="server" Key="mn-footer" />
    </td>
    </tr>
    </table>
    </form>
    </body>
    </html>

## レイアウトとメッセージテンプレートをバインドします

レイアウトをメッセージテンプレートにバインドするには:

1.  作成したブランチテンプレートのメッセージルートに移動してください。例えば、/sitecore/Templates/Branches/System/Email/Messages/Custom newsletter/Monthly newsletter/Name/Message rootなどです。
    
2.  **プレゼンテーション**タブの**レイアウト**グループで**「詳細**」をクリックします。
    
3.  レイアウト **詳細** ダイアログボックスの **デフォルト** デバイスについては*、\[指定されていないレイアウト\]*リンクをクリックしてください。
    
    ![Layout\_details\_dialog.png](https://doc.sitecore.com/api/markdown-image/xp/ja/developers/exm/91/email-experience-manager/images/Layout_details_dialog.png)
    
4.  **デバイスエディター**のダイアログの**レイアウト**タブで、ドロップダウンメニューをクリックして作成したレイアウトに移動します。例えば*Monthly newsletter*。
    
    ![Device\_editor.png](https://doc.sitecore.com/api/markdown-image/xp/ja/developers/exm/91/email-experience-manager/images/Device_editor.png)
    
5.  **コントロール**タブで、関連するコントロールを追加してください。最低限、/Renderings/System/Emailでコントロール「**Set Page Title**」を追加してください。
    
6.  **OK**をクリックします。
    

## テンプレートをEXMで利用可能にしてください

テンプレートをEXMで利用可能にするには:

1.  コンテンツエディターでsitecore/Content/Email/Message Typesに移動します。
    
2.  新しいメッセージテンプレートを追加したいメッセージタイプを展開し、「 **デフォルト** アイテム」をクリックします。
    
3.  **「構成**」タブの「**オプション挿入**」グループで「**割り当て**」をクリックします。
    
4.  オプション **を挿入** ダイアログで、例えばメッセージテンプレートに移動し、/templates/Branches/System/Email/Messages/Custom Newsletter/Monthly Newsletterして **選択** ペインに追加します。
    
    ![Insert\_options.png](https://doc.sitecore.com/api/markdown-image/xp/ja/developers/exm/91/email-experience-manager/images/Insert_options.png)
    
5.  **OK**をクリックして変更を保存してください。
    

EXMでは、ユーザーが新しいメッセージを作成する際にテンプレートリストからメッセージテンプレートを選択できます。

![One-time\_message\_dialog.png](https://doc.sitecore.com/api/markdown-image/xp/ja/developers/exm/91/email-experience-manager/images/One-time_message_dialog.png)