A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Tags: , , ,

TaskItem and AppointmentItem formated body





 
 
Thread Tools Display Modes
  #1  
Old November 8th 06, 03:06 PM posted to microsoft.public.outlook.program_vba
razvantim
external usenet poster
 
Posts: 4
Default TaskItem and AppointmentItem formated body

Is there any way to insert a HTML or RTF text in the body of a TaskItem and
AppointmentItem?
Ads
  #2  
Old November 8th 06, 03:54 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 3,778
Default TaskItem and AppointmentItem formated body

Task and Appointment items always have RTF bodies. You can add RTF to the
body but it must be properly formatted of course and you'd have to set it
using a lower level API than the Outlook object model. If you add formatted
RTF to Body you'd see all the RTF tags and no formatting.

The property you'd need to use is PR_RTF_COMPRESSED (0x10090102), a
PT_BINARY property that would be written as a byte array. The byte array
would be the formatted RTF text.

You would need to use CDO 1.21 or Extended MAPI (C++ or Delphi only) or a
MAPI wrapper such as Redemption (www.dimastr.com/redemption) to be able to
do what you want.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"razvantim" wrote in message
...
Is there any way to insert a HTML or RTF text in the body of a TaskItem
and
AppointmentItem?


  #3  
Old November 8th 06, 05:05 PM posted to microsoft.public.outlook.program_vba
razvantim
external usenet poster
 
Posts: 4
Default TaskItem and AppointmentItem formated body

thx for the respone.

any chance of an example in .NET for saving in RTF format?

i'm using the MAPI library in .net but i can't seem to figure out how to use
PR_RTF_COMPRESSED

"Ken Slovak - [MVP - Outlook]" wrote:

Task and Appointment items always have RTF bodies. You can add RTF to the
body but it must be properly formatted of course and you'd have to set it
using a lower level API than the Outlook object model. If you add formatted
RTF to Body you'd see all the RTF tags and no formatting.

The property you'd need to use is PR_RTF_COMPRESSED (0x10090102), a
PT_BINARY property that would be written as a byte array. The byte array
would be the formatted RTF text.

You would need to use CDO 1.21 or Extended MAPI (C++ or Delphi only) or a
MAPI wrapper such as Redemption (www.dimastr.com/redemption) to be able to
do what you want.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"razvantim" wrote in message
...
Is there any way to insert a HTML or RTF text in the body of a TaskItem
and
AppointmentItem?



  #4  
Old November 8th 06, 07:06 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 3,778
Default TaskItem and AppointmentItem formated body

What MAPI library? If you're using CDO 1.21 that's not supported at all for
use in .NET code. I have no CDO code that is for .NET.

Also, .NET doesn't mean very much, are you using VB or C#?

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"razvantim" wrote in message
...
thx for the respone.

any chance of an example in .NET for saving in RTF format?

i'm using the MAPI library in .net but i can't seem to figure out how to
use
PR_RTF_COMPRESSED


  #5  
Old November 8th 06, 07:42 PM posted to microsoft.public.outlook.program_vba
Dan Mitchell
external usenet poster
 
Posts: 55
Default TaskItem and AppointmentItem formated body

=?Utf-8?B?cmF6dmFudGlt?= wrote in
:
i'm using the MAPI library in .net but i can't seem to figure out how
to use PR_RTF_COMPRESSED


If you were using ExMAPI normally, you'd do:

OpenProperty(PR_RTF_COMPRESSED) to get the compressed stream
WrapCompressedRTFStream() to get an uncompressed stream out

then use standard IStream operations on that stream, and call RTFSync
when you're done. See the documentation for PR_RTF_COMPRESSED,
basically.

I don't know what's in the "MAPI library" you're using, but you should
look for functions that are similar to those ones. I don't know which
bit of the CLR is for IStream once you're out of the ExMAPI code, but
there must be something in there somewhere.

Oh, and as Ken mentions, .Net + CDO1.21 (or ExMAPI) aren't supported.
They may work, but if mysterious things go wrong, the answer is "don't
mix those things".

http://support.microsoft.com/kb/813349
http://support.microsoft.com/kb/872895

-- dan
  #6  
Old November 9th 06, 08:14 AM posted to microsoft.public.outlook.program_vba
razvantim
external usenet poster
 
Posts: 4
Default TaskItem and AppointmentItem formated body

i have developed an application in VS2005 C# that manipulates outlook unsing
VSTO. but now i'm verry frustrated i can't add RTF content or any formated
content in body of an appoinmnent or task. I woud really apreciate an example
in C# how to open a mail based by its ID or any other cryteria and simply
change its body content to a RTF one.
  #7  
Old November 9th 06, 05:12 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 3,778
Default TaskItem and AppointmentItem formated body

As mentioned before you need to use a lower level API than the Outlook
object model to do what you want. You should not be using CDO 1.21 or
Extended MAPI from .NET code. It might work but when you run into problems
there are no fixes or support, since it's not supported. CDO is also subject
to the Outlook security and is not installed by default when Office is
installed, although it's an optional installation on the Office CD's.

You can use Redemption for what you want but it's a 3rd party library and
must be purchased if you intend to distribute your code.

What I would recommend would be to create a COM wrapper around the CDO code
calls if you want to use CDO and calling your COM wrapper DLL from your .NET
code. That would avoid the problems of directly calling CDO code from .NET
code.

Here is how the code would look (using VB 6) from the COM side, to call CDO,
which requires a reference to be set to CDO 1.21 (CDO.DLL) not one of the
many other CDO's.

' code would get EntryID of the task or appointment passed in to it
Dim oSession As MAPI.Session
Dim oMessage As MAPI.Message
Dim oField As MAPI.Field

Const PR_RTF_COMPRESSED = &H100901102

Set oSession = CreateObject("MAPI.Session")

'only works if Outlook is already running
oSession.Logon "", "", False, False

Set oMessage = oSession.GetItem(strEntryID)
Set oField = oMessage.Fields(PR_RTF_COMPRESSED)
'that field will be Empty if no body text exists for the task or appt.
' check for IsEmpty() before trying to use and handle access errors.

You would add your RTF formatted data to that field as follows:

oField.Value = strRTFtext
oMessage.Update

then set everything to Nothing after using oSession.Logoff to release the
session.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"razvantim" wrote in message
...
i have developed an application in VS2005 C# that manipulates outlook
unsing
VSTO. but now i'm verry frustrated i can't add RTF content or any formated
content in body of an appoinmnent or task. I woud really apreciate an
example
in C# how to open a mail based by its ID or any other cryteria and simply
change its body content to a RTF one.


  #8  
Old November 9th 06, 05:45 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 3,778
Default TaskItem and AppointmentItem formated body

Ooops. I forgot when I wrote that quickie code snippet that
PR_RTF_COMPRESSED is a PT_BINARY and not a PT_STRING8 property. That means
you will need to convert the string containing the RTF from string into a
byte array before you set the field to the value.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Ken Slovak - [MVP - Outlook]" wrote in message
...
As mentioned before you need to use a lower level API than the Outlook
object model to do what you want. You should not be using CDO 1.21 or
Extended MAPI from .NET code. It might work but when you run into problems
there are no fixes or support, since it's not supported. CDO is also
subject to the Outlook security and is not installed by default when
Office is installed, although it's an optional installation on the Office
CD's.

You can use Redemption for what you want but it's a 3rd party library and
must be purchased if you intend to distribute your code.

What I would recommend would be to create a COM wrapper around the CDO
code calls if you want to use CDO and calling your COM wrapper DLL from
your .NET code. That would avoid the problems of directly calling CDO code
from .NET code.

Here is how the code would look (using VB 6) from the COM side, to call
CDO, which requires a reference to be set to CDO 1.21 (CDO.DLL) not one of
the many other CDO's.

' code would get EntryID of the task or appointment passed in to it
Dim oSession As MAPI.Session
Dim oMessage As MAPI.Message
Dim oField As MAPI.Field

Const PR_RTF_COMPRESSED = &H100901102

Set oSession = CreateObject("MAPI.Session")

'only works if Outlook is already running
oSession.Logon "", "", False, False

Set oMessage = oSession.GetItem(strEntryID)
Set oField = oMessage.Fields(PR_RTF_COMPRESSED)
'that field will be Empty if no body text exists for the task or appt.
' check for IsEmpty() before trying to use and handle access errors.

You would add your RTF formatted data to that field as follows:

oField.Value = strRTFtext
oMessage.Update

then set everything to Nothing after using oSession.Logoff to release the
session.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


  #9  
Old November 9th 06, 06:06 PM posted to microsoft.public.outlook.program_vba
Dan Mitchell
external usenet poster
 
Posts: 55
Default TaskItem and AppointmentItem formated body

"Ken Slovak - [MVP - Outlook]" wrote in
:
Ooops. I forgot when I wrote that quickie code snippet that
PR_RTF_COMPRESSED is a PT_BINARY and not a PT_STRING8 property. That
means you will need to convert the string containing the RTF from
string into a byte array before you set the field to the value.


And it has to be a _compressed_ byte array, thus the call to
WrapCompressedRTFStream. I don't think you can do this at all with just
plain CDO1.21 -- see

http://support.microsoft.com/kb/q172038/

for a helper DLL, though.

-- dan

  #10  
Old November 10th 06, 12:32 PM posted to microsoft.public.outlook.program_vba
razvantim
external usenet poster
 
Posts: 4
Default TaskItem and AppointmentItem formated body

i've managed with CDO 1.2 to access CdoPR_RTF_COMPRESSED.

here is the C# code i've used

MAPI.Session session = new MAPI.Session();
session.Logon(Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value);
MAPI.Message msg =
(MAPI.Message)session.GetMessage("000000008412BE0A 84F77C48BB16457F22A3A74124702500", Missing.Value);

MAPI.Fields flds = (MAPI.Fields)msg.Fields;
MAPI.Field fls =
(MAPI.Field)flds.get_Item(MAPI.CdoPropTags.CdoPR_R TF_COMPRESSED,
Missing.Value);

how can i convert a string so the fls.value will accept it?

dan, the dll you poninted me (mapirtf.dll) to convert string to rtf
compressed binary is not working when i try to register or use it.
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
help: AppointmentItem.copy fail problem meokey Outlook and VBA 2 October 31st 06 04:07 PM
How can i make AppointmentItem not editable in the calendar? eranhef@gmail.com Outlook - Using Forms 0 September 19th 06 07:59 AM
How to access the Private property on a Outlook.AppointmentItem PromisedOyster Outlook and VBA 1 August 11th 06 01:26 PM
How to create AppointmentItem in inbox (Outlook 2002) Galois Add-ins for Outlook 2 April 27th 06 09:01 AM
AppointmentItem question (2003) Dana DeLouis Outlook and VBA 1 January 18th 06 06:13 PM


All times are GMT +1. The time now is 04:45 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2008 Outlook Banter, part of the NewsgroupBanter project.
The comments are property of their posters.
Loans - Wikipedia - Best Credit Cards - Car Loan - Credit Card