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

FONT - programming RTF in the body

83 views
Skip to first unread message

Jan G. Thorstensen

unread,
Jan 25, 2001, 4:24:03 AM1/25/01
to
Hi, I am a beginner when it comes to programming vba in Outlook2000
(windows98).

When I try to display a Task Item with the associated inspector,
I also want to add some text. That's Ok. The problem
is however, to f o r m a t the text in the body so that I can
have a header with bold font and say, font size 16 and the rest
of the text Arial, font size 12. How do I do this ?

Can somebody please show me some code example that does this?
Any help will be very much appriciated - thanks in advance.

Regards Jan

------------------------------------------
The code below is in an Excel workbook.
------------------------------------------
Sub Intervju_Appointment()
Dim MyOlApp As Object
Dim MyItem As Object
'Dim MyAttachments As Attachments
Set MyOlApp = CreateObject("Outlook.Application")
Set MyItem = MyOlApp.CreateItem(olAppointmentItem)
MyItem.Subject = "Intervju - vedr. stilling som xxx"
MyItem.Body = "This should be the header; Bold Font size 16" _
& vbCrLf & vbCrLf _
& "Click teh icon to open the Sales Results." & Chr(13)
'Set MyAttachments = MyItem.Attachments
'MyAttachments.Add "C:\Mine dokumenter\Hei.doc", olByValue, 1, _
"Prøvedokument"
MyItem.Display
End Sub

(PS : The code is slightly modified. It is taken from the book
Building Applications with Outlook2ooo. I' m also having
problem with the attachments - code, wich generates an error ?)


Sue Mosher [MVP]

unread,
Jan 25, 2001, 7:43:24 AM1/25/01
to
There's no easy solution for this. You'd have to build the RTF either
directly using the RTF syntax or by saving a Word document in RTF format,
then use CDO and a special DLL to put the formatted body into the Outlook
item. See http://www.slipstick.com/dev/formatmsg.htm.

--
Sue Mosher, Outlook MVP
Author of
Teach Yourself Microsoft Outlook 2000 Programming in 24 Hours
Microsoft Outlook 2000 E-mail and Fax Guide
Outlook and Exchange solutions at http://www.slipstick.com

"Jan G. Thorstensen" <jgth...@online.no> wrote in message
news:%oSb6.527$jQ1....@news1.oke.nextra.no...

Jan G. Thorstensen

unread,
Jan 25, 2001, 4:17:07 PM1/25/01
to
Thank you, Sue Mosher, for your quick answer.
I have just learned a few tricks to manipulate Outlook 2000 (and also OL 98
at work).
I will certainly read your site wich you're referring to below to learn
this. You
saved me for hours and hours of work if I had tried to find out on my own.
Thank's again!

Jan
-----------------

Sue Mosher [MVP] <sue...@slipstick.com> skrev i
meldingsnyheter:uTtZibthAHA.1728@tkmsftngp02...

Perry

unread,
Jan 26, 2001, 3:43:36 PM1/26/01
to
You'd think this would be easy, wouldn't you? Nuh-uh.

Sue Mosher at Slipstick.com posted a very helpful link on another group:
http://www.slipstick.com/dev/formatmsg.htm

What the info there tells you, though, is that you need to get a special dll
called mapirtf.dll, which provides a method (writertf) that writes a string of
rich text out to a message, once it exists. So you have to create the message,
get its ID and close it; somehow get your body in Rich Text (in Word, you can
save in Rich Text than read back in from code as text; or you can copy to the
clipboard and use more API calls to read the RTF back in); then call writertf.

Another wrinkle: so far I haven't gotten this to work for a message created with
the Outlook object model. I had to use CDO to create the message instead, which
is a whole other object model, and takes longer because it establishes a separate
MAPI stream. The messages appear identical, but writertf fails on the Outlook
one.

Sue was thinking of posting a sample of what I've accomplished so far; not sure
if she has. If you want more, email me directly at ul...@home.com; I don't
monitor this group very often.

Cheers... Perry.

Regards Jan


.

0 new messages