Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to format (html) appointment body? Outlook VSTO

2,612 views
Skip to first unread message

musa.biralo

unread,
May 2, 2010, 11:44:14 AM5/2/10
to
Hi,

I am trying to create a formatted appointment body but the only method
I can see in the appointmentItem is body. This method only writes the
plain text not the formatted html body.

what i simply like to do is
appointmentItem.HTMLBody = emailItem.HTMLBody

but the HTMLBody is not availabe under AppointmentItem :(

So, what is the approach of formatting an appointment body?

Thank you.

musa.biralo

unread,
May 2, 2010, 1:38:19 PM5/2/10
to
Looks like this is the only method.... but i am stuck at another
simple issue :(


Dim appointmentItem As Outlook.AppointmentItem =
Globals.ThisAddIn.Application.CreateItem(Outlook.OlItemType.olAppointmentItem)
CopyEmailBodyToAppointmentBody(selectedMail, appointmentItem)

'--------------------

Private Function CopyEmailBodyToAppointmentBody(ByVal email As
Microsoft.Office.Interop.Outlook.MailItem, _
ByVal appointment As
Microsoft.Office.Interop.Outlook.AppointmentItem) As Boolean

If email Is Nothing OrElse appointment Is Nothing Then
Return False
End If

Try

Dim emailWordDocument As Microsoft.Office.Interop.Word.Document
= email.GetInspector.WordEditor
Dim emailWordSelection As
Microsoft.Office.Interop.Word.Selection =
emailWordDocument.Windows(1).Selection

Dim appointmentWordDocument As
Microsoft.Office.Interop.Word.Document =
appointment.GetInspector.WordEditor
Dim appointmentWordSelection As
Microsoft.Office.Interop.Word.Selection =
emailWordDocument.Windows(1).Selection

emailWordSelection.WholeStory()
emailWordSelection.Copy()


appointmentWordSelection.PasteAndFormat(Microsoft.Office.Interop.Word.WdRecoveryType.wdPasteDefault)
'<---- Error
' Error = This method or property is not available because the
document is locked for editing.
' I am clueless on resolving this. What do I need to do to
resolve this? Thanks.

Catch ex As Exception
Return False
End Try

Return True

End Function

Original Source Code : http://www.outlookcode.com/codedetail.aspx?id=2040

Thanks for your help.
Musa.

Ken Slovak - [MVP - Outlook]

unread,
May 3, 2010, 1:13:27 PM5/3/10
to
There is no HTMLBody property because that type of item doesn't support
HTML. You can only provide formatting using RTF (Rich Text format) and
provide it in the PR_RTF_COMPRESSED property, which is a binary property
(you'd write to it as an array of hex coded bytes). The DASL property tag
for PR_RTF_COMPRESSED is
"http://schemas.microsoft.com/mapi/proptag/0x10090102".

You would have to create syntactically correct RTF text and write it to that
property. You may want to re-think your efforts, RTF is a real beast to work
with. Also, in Outlook 2007 the PropertyAccessor will be able to write that
property but won't be able to read it if the contents of the property are
larger than about 8 KB.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"musa.biralo" <musa....@gmail.com> wrote in message
news:a7e76c13-d567-45bf...@37g2000yqm.googlegroups.com...

muas

unread,
May 3, 2010, 4:23:41 PM5/3/10
to
Thanks Ken for the reply.

From the post of Sue in http://www.outlookcode.com/codedetail.aspx?id=2040
it does not appear that it will be too hard.

The problem, i got stuck at is now little bit different:


Error = "This method or property is not available because the document

is locked for editing". Second post from bottom shows where this error
is coming from

How can I resolve this?
Thanks

On May 3, 9:13 am, "Ken Slovak - [MVP - Outlook]" <kenslo...@mvps.org>
wrote:


> There is no HTMLBody property because that type of item doesn't support
> HTML. You can only provide formatting using RTF (Rich Text format) and
> provide it in the PR_RTF_COMPRESSED property, which is a binary property
> (you'd write to it as an array of hex coded bytes). The DASL property tag
> for PR_RTF_COMPRESSED is
> "http://schemas.microsoft.com/mapi/proptag/0x10090102".
>
> You would have to create syntactically correct RTF text and write it to that
> property. You may want to re-think your efforts, RTF is a real beast to work
> with. Also, in Outlook 2007 the PropertyAccessor will be able to write that
> property but won't be able to read it if the contents of the property are
> larger than about 8 KB.
>
> --
> Ken Slovak
> [MVP - Outlook]http://www.slovaktech.com
> Author: Professional Programming Outlook 2007.
> Reminder Manager, Extended Reminders, Attachment Options.http://www.slovaktech.com/products.htm
>

> "musa.biralo" <musa.bir...@gmail.com> wrote in message

Ken Slovak - [MVP - Outlook]

unread,
May 3, 2010, 5:54:49 PM5/3/10
to
I saw that Word error message you posted about, as far as I know you can't
do anything about it. You might get additional information on bypassing the
error in a Word programming group. If you can't do anything about the
problem then you'd be stuck doing what I said.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"muas" <mine...@gmail.com> wrote in message
news:ad17c3ed-c000-456e...@h9g2000yqm.googlegroups.com...

0 new messages