Hi there!
I am using Aspose.Email version 25.2.0 in Openedge 12.8.9. I am making a basic MailMessage variable with IsBodyHtml set to True and I have set the priority tag parameter to MailPriority:High. The file is saved as an EML file using the save method in MailMessage class and opened in the newest Outlook to be amended using
OS-COMMAND NO-WAIT VALUE( ‘"’ + l_emailPath + ‘"’ ).
This opens the email in Outlook but the priority tag is never properly set when opened.
The EML file created is below with the to parameter redacted:
X-Unsent: 1
Subject: importance-high
To:
Priority: Urgent
X-Priority: High
Importance: High
Content-Type: text/html; charset=“us-ascii”
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
importance-high-body
If I replace the Content-Type with an invalid one, the headers are then correctly read but the body gets turned into an attachment.
image.png (6.2 KB)
If I use both the body and HtmlBody elements for the MailMessage and force the text/plain content type with an invalid one, it then works correctly.
image.png (2.5 KB)
File created with both body and htmlBody:
X-Unsent: 1
Subject: importance-high
To:
Priority: urgent
X-Priority: High
Importance: High
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary=“–_=_NextPart1_336f7a5d-1441-4339-bedb-97d2c451c4c8”
This is a multi-part message in MIME format.
----_=_NextPart1_336f7a5d-1441-4339-bedb-97d2c451c4c8
Content-Type: text/plain-text; charset=“us-ascii”
Content-Transfer-Encoding: quoted-printable
importance-high
----_=_NextPart1_336f7a5d-1441-4339-bedb-97d2c451c4c8
Content-Type: text/html; charset=“us-ascii”
Content-Transfer-Encoding: quoted-printable
importance-high
----_=_NextPart1_336f7a5d-1441-4339-bedb-97d2c451c4c8–
Can someone explain why this is happening and is there a more optimal way to get this working?
@LNGLEEVFDEV
Summary
When Aspose.Email creates an EML that contains only an HTML part, the priority‑related headers (Priority, X‑Priority, Importance) are written with low‑priority values. Outlook reads those headers correctly only when the message is multipart (e.g., has a plain‑text part).
Why it happens
- For a single‑part HTML message Aspose.Email writes the three Outlook‑specific headers, but the values default to “low” (e.g.,
Priority: non‑urgent).
- When the message is multipart/alternative (both
Body and HtmlBody are present) the same headers are written with the high‑priority values (Priority: urgent, X‑Priority: High, Importance: High).
What to do next
- Create a multipart message – include both a plain‑text body and an HTML body.
var msg = new MailMessage();
msg.From = "sender@domain.com";
msg.To.Add("receiver@domain.com");
msg.Subject = "importance‑high";
msg.Priority = MailPriority.High; // sets the three headers
msg.Body = "importance‑high"; // plain‑text part
msg.HtmlBody = "<p>importance‑high</p>"; // HTML part
msg.Save("test.eml", SaveOptions.DefaultEml);
This generates a multipart/alternative EML, and Outlook shows the high priority correctly.
I copied the wrong file and instead wrote the low priority test I was doing. I’ve replaced it with the high priority test. My message is multipart without having the incorrect Content-Type but it still doesn’t pick up the priority tag. It only picks up the tag if one of the content types are incorrect.
New generated file:
X-Unsent: 1
Subject: importance-high
To:
Priority: urgent
X-Priority: High
Importance: High
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary=“–_=_NextPart2_5f09dd78-daac-4cc5-b1d0-efa681fea3d8”
This is a multi-part message in MIME format.
----_=_NextPart2_5f09dd78-daac-4cc5-b1d0-efa681fea3d8
Content-Type: text/plain; charset=“utf-8”
Content-Transfer-Encoding: quoted-printable
importance-high
----_=_NextPart2_5f09dd78-daac-4cc5-b1d0-efa681fea3d8
Content-Type: text/html; charset=“us-ascii”
Content-Transfer-Encoding: quoted-printable
importance-high
----_=_NextPart2_5f09dd78-daac-4cc5-b1d0-efa681fea3d8–
@LNGLEEVFDEV
When the MailMessage is created with IsBodyHtml set to True and saved as an EML with Aspose.Email 25.2.0, the file contains the headers
Priority: Urgent
X-Priority: High
Importance: High
According to the evidence, when Aspose.Email creates an EML that contains only an HTML part, the priority‑related headers (Priority, X‑Priority, Importance) are written with low‑priority values. Outlook reads those low‑priority values, so the message is not shown as high priority.
If the Content‑Type header is replaced with an invalid value, the priority headers are then read correctly by Outlook, but the body is turned into an attachment.
If both the Body and HtmlBody elements are used and the Content‑Type is forced to an invalid text/plain value, the priority tag is recognized correctly.