MailMessage.Headers and Content-Type

  • Thread starter Thread starter Vlad
  • Start date Start date
V

Vlad

We are trying to set MailMessage Content-Type to be text/calendar
The following code has been used:
string subject = "Calendar test 3";
MailMessage emailMessage = new MailMessage();
emailMessage.To = <address>
emailMessage.Subject = "my subject";
emailMessage.Headers.Add("Content-Type","text/calendar;method=\"REQUEST\"");
emailMessage.Body=@"BEGIN:VCALENDAR
PRODID:-//ACME/DesktopCalendar//EN
METHOD:REQUEST
VERSION:2.0....<the rest of iCalendar>
";
MailService.Send(emailMessage);

Even though the content-type was specified in Headers collection the
resulting message still contains "text/plain" content-type.

Please help.

Vlad
 
You probably need to set the BodyFormat property on your MailMessage
object to get the content-type to what you want.

Example:

MailMessage mail = new MailMessage();
mail.To = <address>
mail.From = <address>
mail.Subject = emailSubject;
mail.BodyFormat = System.Web.Mail.MailFormat.Html;

Hope that helps

http://www.harleyc.com
 
I dont think it has anything to do with HTML/Plain text. Content-type is
email header--not HTTP header. I tried it anyways just to be safe and got
the same results - plain text.

Still need MSFT help with this!
 
I believe that if the email reader does not support the "text/calendar"
type, it is probably converting it to "text/plain". Why email reader are
you using? If you have a web access email account, you might try sending an
email to that account and view it in something like FireFox which supports
"text/calendar".
 
Actually we use MS Outlook 2003 which does support it. We tried it with a
custom third-party component that sets the header fine. However when we did
it through .NET native component it didn't work.
 
Actually we use MS Outlook 2003 which does support it. We tried it with a
custom third-party component that sets the header fine. However when we did
it through .NET native component it didn't work.
 
Back
Top