When you run a mail merge in Word and send emails through Outlook, the subject line sometimes displays raw field codes like {MERGEFIELD Subject} instead of the actual merged data. This problem occurs because Outlook interprets the subject field as plain text rather than executing the merge field instruction. The root cause is usually a missing or incorrect field switch in the subject line or a mismatch between the merge field name and the data source column header. This article explains why the raw code appears and provides a step-by-step fix to ensure the subject line shows the correct merged content.
Key Takeaways: Fixing Raw Merge Field Code in the Subject Line
- Insert > Quick Parts > Field > MergeField > Add the \ MERGEFORMAT switch: Forces Word to display the merged value instead of the raw field code in the subject line.
- Press Alt+F9 to toggle field code display: Reveals or hides all field codes in the document so you can verify the subject line contains a MergeField field, not plain text.
- Mailings > Finish & Merge > Send E-mail Messages > Subject line box: Enter the merge field name exactly as it appears in your data source to avoid mismatches.
Why the Subject Line Shows Raw Field Code Instead of Merged Data
During a mail merge to email, Word builds a temporary Outlook message for each recipient. The subject line of that message must contain a merge field that Word can evaluate. If the subject line contains the merge field as plain text — for example, you typed {MERGEFIELD Subject} directly — Outlook treats it as literal characters. The field code does not get executed because Word only evaluates fields inside the main document body, not in the subject line dialog box.
Another cause is a mismatch between the field name you used and the column header in your data source. If the data source has a column named “SubjectLine” but you typed “Subject” in the subject line field, Word cannot find the data and leaves the raw code visible. Additionally, if the \ MERGEFORMAT switch is missing from the MergeField field, Word may display the field code instead of the result in certain Outlook versions.
Steps to Fix the Raw Code in the Mail Merge Subject Line
The fix requires inserting a proper MergeField field into the subject line using Word’s field dialog. Follow these steps to replace the raw code with a working merge field.
- Open the mail merge main document
Launch Word and open the document that contains your mail merge. This is the document you set up with recipient placeholders and the email body. - Go to Mailings > Start Mail Merge > E-mail Messages
Confirm that the merge type is set to email. If it is set to Letters or another type, change it to E-mail Messages. This step ensures the merge outputs to Outlook. - Click Mailings > Finish & Merge > Send E-mail Messages
A dialog box opens. This is where you set the subject line and other email options. - Delete any raw code from the Subject line box
If the Subject line box contains text like {MERGEFIELD Subject}, select it and press Delete. Do not type anything yet. - Insert a MergeField field using the Field dialog
Click inside the Subject line box. Do not close the dialog. Press Alt+F9 to toggle field code display in the main document — this does not affect the Subject line box directly. Instead, you need to insert the field via a workaround: Close the Send E-mail Messages dialog. In the main document body, place the cursor where you want a test field. Press Ctrl+F9 to insert an empty field brace. Type MERGEFIELD Subject inside the braces. Press F9 to update the field. Press Alt+F9 to toggle back to field results. Copy the entire field including the braces. Press Mailings > Finish & Merge > Send E-mail Messages again. Paste the copied field into the Subject line box. - Add the \ MERGEFORMAT switch
Right-click the pasted field in the Subject line box and choose Toggle Field Codes. Add \ MERGEFORMAT after the field name, so it reads MERGEFIELD Subject \ MERGEFORMAT. Press F9 to update. - Run a test merge to a single recipient
Click Mailings > Preview Results. Verify that the subject line in the preview shows the actual data, not the field code. If it still shows raw code, press Alt+F9 to check if the field code is visible. Repeat steps 5 and 6. - Complete the merge
Click Mailings > Finish & Merge > Send E-mail Messages. Enter the recipient list and send the emails. Check the Outlook Sent Items folder for a sample email to confirm the subject line is correct.
If the Subject Line Still Shows Raw Code After the Fix
Word Shows Field Codes Instead of Results in the Main Document
If the entire document displays field codes like {MERGEFIELD FirstName} in the body and subject, you have field code display turned on globally. Press Alt+F9 to toggle all fields to show results. Then run the merge again.
Outlook Security Blocks the Merge Field Execution
Some Outlook security settings prevent Word from injecting merge fields into the subject line. Add the data source file location to Outlook’s trusted locations. In Outlook, go to File > Options > Trust Center > Trust Center Settings > Email Security > Programmatic Access > Never warn me about suspicious activity. Restart Outlook and Word, then rerun the merge.
The Merge Field Name Does Not Match the Data Source Column
Open your data source in Excel or a text editor. Note the exact column header name, including spaces and capitalization. In Word, while in the Send E-mail Messages dialog, delete the existing field and reinsert it using the correct name. For example, if the column is “Email Subject”, use MERGEFIELD “Email Subject” with quotes.
Word Mail Merge Subject Line Methods: Field Dialog vs Manual Typing
| Item | Field Dialog Method | Manual Typing Method |
|---|---|---|
| How to insert | Insert > Quick Parts > Field > MergeField > Select field name | Type {MERGEFIELD Subject} directly |
| Field switches | Automatically adds \ MERGEFORMAT | No switch added by default |
| Subject line result | Shows merged data | Shows raw field code |
| Reliability | Works correctly in most Outlook versions | Fails in Outlook 2016 and later |
After applying the field dialog method and adding the \ MERGEFORMAT switch, your mail merge subject line will display the correct merged content in Outlook. To avoid this issue in future merges, always use the Insert > Quick Parts > Field dialog when adding merge fields to the email subject line. If you frequently send bulk emails, consider saving a mail merge template with the subject line field already inserted correctly.