Re: how can one turn off Content-Type: text/ht - WeOnlyDo Discussion board

Re: how can one turn off Content-Type: text/ht (General questions)

by Glenn, Saturday, December 08, 2007, 23:35 (5986 days ago) @ wodDamir

Hi Damba,

I tried CreateSimple() and CreateTextHTML() and these are good.

Here is what seems to be happening - please correct me if I'm wrong.

When you call CreateSimple() it deletes all the Message Parts (if any).
It also deletes the Headers (including any custom headers you may
have added) and rebuilds them, using parameters passed to CreateSimple().
During the headers rebuild, it sets the Message Content-Type to text/plain .

When you call CreateTextHTML() it creates 2 message Parts (in the Parts collection).
Part 0 has the PlainText, and Part 1 has the HTMLText.
It also deletes the Headers (including any custom headers you may
have added) and rebuilds them, using parameters passed to CreateTextHTML().
During the headers rebuild, it sets the Message Content-Type to multipart/alternative .
Appropriate parts boundaries are put in the body.

When you assign the Message.PlainText to something.
A new Part with Content-Type = text/plain is created,
and the Content-Type of the message itself is set to multipart/alternative .

Similarly, when you assign the Message.HTMLText to something.
A new Part with Content-Type = text/html is created,
and the Content-Type of the message itself is set to multipart/alternative .

The only way to remove all the Parts seems to be calling CreateSimple(),
but this has the side effect of deleting the Message Headers too.
So it would be nice if the Parts collection had an explicit RemoveAll(),
like SmtpHdrs, for experienced users.

After posting my question, and before you suggested CreateSimple() and CreateTextHTML(),
I found a workaround, but not as nice.
Instead of:
m_Mailer.Message.HTMLText =
you can do
m_Mailer.Message.Parts.Item(1).Body =
This has the effect that no text/html part appears in the message -
there is absolutely nothing between the appropriate boundaries.
But the Content-Type of the message itself is still multipart/alternative (not as nice).

Note that this contradicts the documentation, which says
Body is a readonly property ...
Writing to Body property is not possible.

Glenn


Complete thread: