Thursday, March 29, 2012

MailMessage.Headers and Content-Type

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=@dotnet.itags.org."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.

VladYou 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

Vlad wrote:
> 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
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!

<guidomuffin@.hotmail.com> wrote in message
news:1145909503.988524.208540@.i39g2000cwa.googlegr oups.com...
> 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
>
> Vlad wrote:
>> 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
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".
--
Christopher A. Reed
"The oxen are slow, but the earth is patient."

"Vlad" <Vlad@.community.nospam> wrote in message
news:exIsoGMaGHA.4416@.TK2MSFTNGP04.phx.gbl...
>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!
> <guidomuffin@.hotmail.com> wrote in message
> news:1145909503.988524.208540@.i39g2000cwa.googlegr oups.com...
>> 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
>>
>>
>> Vlad wrote:
>>> 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
>>
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.

--
Vlad
P.S. Please remove "REMOVETHIS" from my email address to reply...
"Christopher Reed" <carttu@.nospam.nospam> wrote in message
news:%23QNO$aOaGHA.4780@.TK2MSFTNGP02.phx.gbl...
>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".
> --
> Christopher A. Reed
> "The oxen are slow, but the earth is patient."
> "Vlad" <Vlad@.community.nospam> wrote in message
> news:exIsoGMaGHA.4416@.TK2MSFTNGP04.phx.gbl...
>>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!
>>
>> <guidomuffin@.hotmail.com> wrote in message
>> news:1145909503.988524.208540@.i39g2000cwa.googlegr oups.com...
>>> 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
>>>
>>>
>>> Vlad wrote:
>>>> 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
>>>
>>
>>
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.

"Christopher Reed" <carttu@.nospam.nospam> wrote in message
news:%23QNO$aOaGHA.4780@.TK2MSFTNGP02.phx.gbl...
>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".
> --
> Christopher A. Reed
> "The oxen are slow, but the earth is patient."
> "Vlad" <Vlad@.community.nospam> wrote in message
> news:exIsoGMaGHA.4416@.TK2MSFTNGP04.phx.gbl...
>>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!
>>
>> <guidomuffin@.hotmail.com> wrote in message
>> news:1145909503.988524.208540@.i39g2000cwa.googlegr oups.com...
>>> 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
>>>
>>>
>>> Vlad wrote:
>>>> 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
>>>
>>
>>

0 comments:

Post a Comment