Send RTF formatted e-mail with outlook

C

Chris Zopers

Hello,

I want to send an RTF formatted e-mail with Outlook. I read somewhere
that just assigning some rtf-code to the Mail.Body property won't work.
So I tried the code that I found on
http://www.outlookcode.com/d/formatmsg.htm#wordmail (I added this code
at the end of this message)

Making a new RTF-formatted e-mail works just fine, but the receiver of
the message always sees the e-mail as plain text (no matter which e-mail
format (plain text, rtf or html) he/she selected).

Does anyone know how to send RTF e-mails, so that the receiver also sees
the e-mail as RTF?

Greetings,
Chris

Code:

Dim objSession, objMessage, objMessageFilter As Object
Dim MessageID, cRTF As String
Dim bRet As Integer

Set objSession = CreateObject("MAPI.Session")
objSession.Logon

' Read the first message in the Inbox
Set objMessage = objSession.Inbox.Messages(1)
objMessage.Update ' to get a permanent Entry ID
MessageID = objMessage.ID

' We must initialize the string variable we are passing
' to a string of the maximum length we want to read
cRTF = Space(500)
bRet = ReadRTF(objSession.Name, objMessage.ID, _
objMessage.StoreID, cRTF)

If Not bRet = 0 Then
MsgBox "RTF Not Written Successfully"
Else
MsgBox "RTF Text: " & Chr(13) & cRTF
End If

Set objMessage = Nothing
objSession.Logoff
Set objSession = Nothing
 
S

Sue Mosher [MVP-Outlook]

Information about your version of Outlook and mail accounts is crucial to understanding your scenario.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
C

Chris Zopers

Hello Sue,

I use Microsoft Outlook 2000, but I have the same problem with Microsoft
Oulookt 2003.....
 
S

Sue Mosher [MVP-Outlook]

And the mail server is?

Also note: The newsgroup interface you are using apparently does not quote earlier messages in the thread, making your latest message so short on detail that you risk not getting the answer you're looking for. Please take the time to quote the original message.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
C

Chris Zopers

Hello Sue,

I use Microsoft Outlook 2000, but the same problem occurs with Microsoft
Outlook 2003. I do not use a mail server, I send e-mails directly from
my local pc with pop3/smtp.

When I send the e-mail in RTF format, the e-mail is displayed correctly
in my send-items folder in Outlook, but the receiver of the e-mail
always sees plain text, no matter which e-mail format (plain text, rtf
or html) he/she selected. But when I forward the same e-mail from my
send-items folder to the same person, the e-mail is received correctly.
So only when sending the e-mail for the first time the problem
occurs......

Greetings,
Chris.


From: Sue Mosher [MVP-Outlook]
Date Posted: 11/14/2005 6:56:00 AM



Information about your version of Outlook and mail accounts is crucial
to understanding your scenario.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
S

Sue Mosher [MVP-Outlook]

You do indeed use a mail server. It's just running on your local machine.

Can you show the code you're using to set the recipients on the message?
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Chris Zopers said:
Hello Sue,

I use Microsoft Outlook 2000, but the same problem occurs with Microsoft
Outlook 2003. I do not use a mail server, I send e-mails directly from
my local pc with pop3/smtp.

When I send the e-mail in RTF format, the e-mail is displayed correctly
in my send-items folder in Outlook, but the receiver of the e-mail
always sees plain text, no matter which e-mail format (plain text, rtf
or html) he/she selected. But when I forward the same e-mail from my
send-items folder to the same person, the e-mail is received correctly.
So only when sending the e-mail for the first time the problem
occurs......

Greetings,
Chris.


From: Sue Mosher [MVP-Outlook]
Date Posted: 11/14/2005 6:56:00 AM



Information about your version of Outlook and mail accounts is crucial
to understanding your scenario.
 
C

Chris Zopers

Hello Sue,

The actual code I'm using is the code I found at
http://www.outlookcode.com/d/formatmsg.htm#wordmail. I've downloaded a
dll from that website (mapirtf.dll) and placed it in my system32
directory. Here's all code I'm using. This code assumes you have already
a variable (cRTF) which contains some RTF-text. This code opens/shows a
new e-mail in RTF-Format. In that e-mail I just type a recipient and I
send the mail manually by clicking the outlook-button 'send and
receive'. In my send-items folder, the e-mail is displayed correctly in
RTF format, but the recipient just sees plain text.

Public Declare Function WriteRTF _
Lib "mapirtf.dll" _
Alias "writertf" (ByVal ProfileName As String, _
ByVal MessageID As String, _
ByVal StoreID As String, _
ByVal cText As String) _
As Integer

Public Declare Function ReadRTF _
Lib "mapirtf.dll" _
Alias "readrtf" (ByVal ProfileName As String, _
ByVal SrcMsgID As String, _
ByVal SrcStoreID As String, _
ByRef MsgRTF As String) _
As Integer

Public Sub SendEmail

Dim objSession, objMessage, objMessageFilter As Object
Dim MessageID, cRTF As String
Dim bRet As Integer

Set objSession = CreateObject("MAPI.Session")
objSession.Logon

' Read the first message in the Inbox
Set objMessage = objSession.Inbox.Messages(1)
objMessage.Update ' to get a permanent Entry ID
MessageID = objMessage.ID

' We must initialize the string variable we are passing
' to a string of the maximum length we want to read
cRTF = Space(500)
bRet = ReadRTF(objSession.Name, objMessage.ID, _
objMessage.StoreID, cRTF)

If Not bRet = 0 Then
MsgBox "RTF Not Written Successfully"
Else
MsgBox "RTF Text: " & Chr(13) & cRTF
End If

Set objMessage = Nothing
objSession.Logoff
Set objSession = Nothing

End Sub
 
S

Sue Mosher [MVP-Outlook]

After you type in the recipient, click the Check Names button on the toolbar to resolve the name. Then double-click the underlined name and make sure the recipient is set for "Send in Outlook rich text format."

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
C

Chris Zopers

Hello Sue,

When I doubleclick on the e-mail adress of the recipient, the properties
dialog is shown. On the 'Name' tab, I see a checkbox called 'e-mail only
as unformatted text' (I use a dutch version of outlook, so I don't know
the exact description of the checkbox in english).

But I don't see an option like 'Send in Outlook rich text format'. Where
should this option be?

Greetings,
Chris.
 
S

Sue Mosher [MVP-Outlook]

You're not using Outlook 2000 in IMO mode are you?

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
C

Chris Zopers

The option 'Internet only' is selected, so I think I'm using IMO mode
indeed. Is that the problem? But we don't have an exchange server or
something like that here. Can I use an other service option in that
case?

Greetings,
Chris.
 
S

Sue Mosher [MVP-Outlook]

Yes, that is potentially a problem. IMO mode provides no way to mark a recipient with a preference for using Rich-Text Format for a message. You might try switching a test machine to Corporate/Workgroup mode to see if that meets your needs. See http://www.slipstick.com/outlook/choosingmode.htm

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
C

Chris Zopers

Okay, I will try that. I'll let you know if that solved my problem, hope
it works....

Greetings,
Chris.
 
C

Chris Zopers

Hello Sue,

I have tried switching from IMO mode to 'business or workgroup'.

After double-clicking the underlined recipient name and setting "Send in
Outlook rich text format.", the e-mail is send AND recieved correctly in
RTF format! Now I'm very close to the solution. The only thing I need to
know now is how to set a recipient to 'Send in Outlook richt text
format' from program-code.

Normally, when I send an e-mail from code, I do this:

Dim objOutlook As Outlook.Application
Dim objMail As Outlook.MailItem

objOutlook = CreateObject("Outlook.Application")
objMail = objoutlook.CreateItem(olMailItem)

objMail.To = "(e-mail address removed)"
objMail.Send

But if I have to set the option 'Send in Outlook richt text format', I
probably have to do this in a different way. Can you help me with that?
How can I set this option?

Greetings,
Chris
 
C

Chris Zopers

Hello Sue,

I've got two questions about the answer at
http://www.outlookcode.com/codedetail.aspx?id=1088

1) Does each person I want to send an RTF-formatted mail to, have to be
in outlook's contactpersons? I get e-mail adresses from a database and
many people work with that database. I hope I don't have to write code
to synchronize all persons in the database with the contactpersons in
outlook.

2) I see they use a Redemtion dll in the sample code. Where can I find
this dll or do I have to purchase this first?

Greetings,
Chris.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top