473,748 Members | 7,118 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I send RTF formated mail using VB.NET?

I am currently using a VB.NET program to send out e-mails with
plain text bodies (plus one attachment). The emails are being
received as Rich Text messages (probably just my personal Outlook
default, because I didn't do this in the program), but there is no
actual formatting (italics, color, etc.) in the message body, which
is passed to from VB.NET to Outlook as an unformatted text String.

I want to start applying formatting to the message body. In
particular, my app has a RichTextBox, which has an Rtf property,
which returns a String formatted as RTF, which contains whatever
my users type or paste into the RichTextBox. That is what I want
to send as the body of the message.

Unfortunately all I get is garbage, like this:

{\rtf1\ansi\ans icpg1252\deff0\ deflang1033{\fo nttbl{\f0\froma n\fprq2\fcharse t0
Times New Roman;}{\f1\fni l\fcharset0 Microsoft Sans Serif;}}
{\colortbl ;\red255\green0 \blue0;}
\viewkind4\uc1\ pard\f0\fs24 This is \cf1 rich\cf0 \b\i text.\par
\b0\i0\par
\pard\f1\fs17\p ar
}

This is of course precisely the content of the input String,
formatting and all. Clearly I have failed to clue Outlook in that
the message body should be interpreted as RTF, not plain text. So
how should I do this?

Here is my code:

=== Begin Example ===
Imports Outlook = Microsoft.Offic e.Interop.Outlo ok

....

Sub MailerRoutine(B yVal Subject As String, ByVal Recipient As String, _
ByVal Body As String, ByVal Filename As String, ByVal displayName As String)

Dim oApp As Outlook.Applica tion = CreateObject("O utlook.Applicat ion")

Dim oItem As Outlook.MailIte m = oApp.CreateItem (Outlook.OlItem Type.olMailItem )

oItem.Subject = Subject
oItem.To = Recipient
oItem.Body = Body
oItem.BodyForma t = Outlook.OlBodyF ormat.olFormatR ichText

Dim bodyLength As String = oItem.Body.Leng th

Dim oAttachments As Outlook.Attachm ents = oItem.Attachmen ts
Dim oAttachment As Outlook.Attachm ent
oAttachment = oAttachments.Ad d(Filename, , bodyLength + 1, displayName)

oItem.Send()

oItem = Nothing
oApp = Nothing
End Sub
=== End Example ===

I got this code from someone else, and I have to admit I don't
really understand how the attachment part work, but that is another
issue. I had thought that adding the line with "olFormatRichTe xt"
would be sufficient to tell Outlook that the message body was RTF,
but clearly it isn't. I'm sure this is really simple, but I just
haven't been able to figure it out, so any help would be appreciated.
--
John Brock
jb****@panix.co m

Nov 21 '05 #1
8 17062
The Outlook object model itself provides technique for creating an RTF message body. You can set BodyFormat, but that just changes the message format. It doesn't give you a way to actually get the RTF content into the message. To do that, the easiest approach is to use the third-party Redemption library. See http://www.outlookcode.com/d/formatmsg.htm

FYI, the general Outlook programming forum is "down the hall" at microsoft.publi c.outlook.progr am_vba
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx
"John Brock" <jb****@panix.c om> wrote in message news:dh******** **@reader1.pani x.com...
I am currently using a VB.NET program to send out e-mails with
plain text bodies (plus one attachment). The emails are being
received as Rich Text messages (probably just my personal Outlook
default, because I didn't do this in the program), but there is no
actual formatting (italics, color, etc.) in the message body, which
is passed to from VB.NET to Outlook as an unformatted text String.

I want to start applying formatting to the message body. In
particular, my app has a RichTextBox, which has an Rtf property,
which returns a String formatted as RTF, which contains whatever
my users type or paste into the RichTextBox. That is what I want
to send as the body of the message.

Unfortunately all I get is garbage, like this:

{\rtf1\ansi\ans icpg1252\deff0\ deflang1033{\fo nttbl{\f0\froma n\fprq2\fcharse t0
Times New Roman;}{\f1\fni l\fcharset0 Microsoft Sans Serif;}}
{\colortbl ;\red255\green0 \blue0;}
\viewkind4\uc1\ pard\f0\fs24 This is \cf1 rich\cf0 \b\i text.\par
\b0\i0\par
\pard\f1\fs17\p ar
}

This is of course precisely the content of the input String,
formatting and all. Clearly I have failed to clue Outlook in that
the message body should be interpreted as RTF, not plain text. So
how should I do this?

Here is my code:

=== Begin Example ===
Imports Outlook = Microsoft.Offic e.Interop.Outlo ok

...

Sub MailerRoutine(B yVal Subject As String, ByVal Recipient As String, _
ByVal Body As String, ByVal Filename As String, ByVal displayName As String)

Dim oApp As Outlook.Applica tion = CreateObject("O utlook.Applicat ion")

Dim oItem As Outlook.MailIte m = oApp.CreateItem (Outlook.OlItem Type.olMailItem )

oItem.Subject = Subject
oItem.To = Recipient
oItem.Body = Body
oItem.BodyForma t = Outlook.OlBodyF ormat.olFormatR ichText

Dim bodyLength As String = oItem.Body.Leng th

Dim oAttachments As Outlook.Attachm ents = oItem.Attachmen ts
Dim oAttachment As Outlook.Attachm ent
oAttachment = oAttachments.Ad d(Filename, , bodyLength + 1, displayName)

oItem.Send()

oItem = Nothing
oApp = Nothing
End Sub
=== End Example ===

I got this code from someone else, and I have to admit I don't
really understand how the attachment part work, but that is another
issue. I had thought that adding the line with "olFormatRichTe xt"
would be sufficient to tell Outlook that the message body was RTF,
but clearly it isn't. I'm sure this is really simple, but I just
haven't been able to figure it out, so any help would be appreciated.
--
John Brock
jb****@panix.co m

Nov 21 '05 #2
And who said newsgroups should not be used to promote one's business ?

:-)
"Sue Mosher [MVP-Outlook]" <su****@outlook code.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
The Outlook object model itself provides technique for creating an RTF
message body. You can set BodyFormat, but that just changes the message
format. It doesn't give you a way to actually get the RTF content into the
message. To do that, the easiest approach is to use the third-party
Redemption library. See http://www.outlookcode.com/d/formatmsg.htm

FYI, the general Outlook programming forum is "down the hall" at
microsoft.publi c.outlook.progr am_vba
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx
"John Brock" <jb****@panix.c om> wrote in message
news:dh******** **@reader1.pani x.com...
I am currently using a VB.NET program to send out e-mails with
plain text bodies (plus one attachment). The emails are being
received as Rich Text messages (probably just my personal Outlook
default, because I didn't do this in the program), but there is no
actual formatting (italics, color, etc.) in the message body, which
is passed to from VB.NET to Outlook as an unformatted text String.

I want to start applying formatting to the message body. In
particular, my app has a RichTextBox, which has an Rtf property,
which returns a String formatted as RTF, which contains whatever
my users type or paste into the RichTextBox. That is what I want
to send as the body of the message.

Unfortunately all I get is garbage, like this:

{\rtf1\ansi\ans icpg1252\deff0\ deflang1033{\fo nttbl{\f0\froma n\fprq2\fcharse t0
Times New Roman;}{\f1\fni l\fcharset0 Microsoft Sans Serif;}}
{\colortbl ;\red255\green0 \blue0;}
\viewkind4\uc1\ pard\f0\fs24 This is \cf1 rich\cf0 \b\i text.\par
\b0\i0\par
\pard\f1\fs17\p ar
}

This is of course precisely the content of the input String,
formatting and all. Clearly I have failed to clue Outlook in that
the message body should be interpreted as RTF, not plain text. So
how should I do this?

Here is my code:

=== Begin Example ===
Imports Outlook = Microsoft.Offic e.Interop.Outlo ok

...

Sub MailerRoutine(B yVal Subject As String, ByVal Recipient As String, _
ByVal Body As String, ByVal Filename As String, ByVal displayName As
String)

Dim oApp As Outlook.Applica tion = CreateObject("O utlook.Applicat ion")

Dim oItem As Outlook.MailIte m =
oApp.CreateItem (Outlook.OlItem Type.olMailItem )

oItem.Subject = Subject
oItem.To = Recipient
oItem.Body = Body
oItem.BodyForma t = Outlook.OlBodyF ormat.olFormatR ichText

Dim bodyLength As String = oItem.Body.Leng th

Dim oAttachments As Outlook.Attachm ents = oItem.Attachmen ts
Dim oAttachment As Outlook.Attachm ent
oAttachment = oAttachments.Ad d(Filename, , bodyLength + 1, displayName)

oItem.Send()

oItem = Nothing
oApp = Nothing
End Sub
=== End Example ===

I got this code from someone else, and I have to admit I don't
really understand how the attachment part work, but that is another
issue. I had thought that adding the line with "olFormatRichTe xt"
would be sufficient to tell Outlook that the message body was RTF,
but clearly it isn't. I'm sure this is really simple, but I just
haven't been able to figure it out, so any help would be appreciated.
--
John Brock
jb****@panix.co m

Nov 21 '05 #3
In article <#w************ **@tk2msftngp13 .phx.gbl>,
Sue Mosher [MVP-Outlook] <su****@outlook code.com> wrote:
The Outlook object model itself provides technique for creating an RTF message body. You can
set BodyFormat, but that just changes the message format. It doesn't give you a way to
actually get the RTF content into the message. To do that, the easiest approach is to use
the third-party Redemption library. See http://www.outlookcode.com/d/formatmsg.htm
I need this tomorrow, and I am afraid that third-party solutions
are out of the question in any case. Since I already have an RTF
formatted text string, are you saying there is no straightforward
way to insert it into an Outlook message? I would have assumed
that Microsoft would make this easy, since it seems like such a
natural thing to want to do, but then you never know with MS.
FYI, the general Outlook programming forum is "down the hall" at
microsoft.publ ic.outlook.prog ram_vba
Thanks, I'll give it a shot.
"John Brock" <jb****@panix.c om> wrote in message news:dh******** **@reader1.pani x.com...
I am currently using a VB.NET program to send out e-mails with
plain text bodies (plus one attachment). The emails are being
received as Rich Text messages (probably just my personal Outlook
default, because I didn't do this in the program), but there is no
actual formatting (italics, color, etc.) in the message body, which
is passed to from VB.NET to Outlook as an unformatted text String.

I want to start applying formatting to the message body. In
particular, my app has a RichTextBox, which has an Rtf property,
which returns a String formatted as RTF, which contains whatever
my users type or paste into the RichTextBox. That is what I want
to send as the body of the message.

Unfortunately all I get is garbage, like this:

{\rtf1\ansi\ans icpg1252\deff0\ deflang1033{\fo nttbl{\f0\froma n\fprq2\fcharse t0
Times New Roman;}{\f1\fni l\fcharset0 Microsoft Sans Serif;}}
{\colortbl ;\red255\green0 \blue0;}
\viewkind4\uc1\ pard\f0\fs24 This is \cf1 rich\cf0 \b\i text.\par
\b0\i0\par
\pard\f1\fs17\p ar
}

This is of course precisely the content of the input String,
formatting and all. Clearly I have failed to clue Outlook in that
the message body should be interpreted as RTF, not plain text. So
how should I do this?

Here is my code:

=== Begin Example ===
Imports Outlook = Microsoft.Offic e.Interop.Outlo ok

...

Sub MailerRoutine(B yVal Subject As String, ByVal Recipient As String, _
ByVal Body As String, ByVal Filename As String, ByVal displayName As String)

Dim oApp As Outlook.Applica tion = CreateObject("O utlook.Applicat ion")

Dim oItem As Outlook.MailIte m = oApp.CreateItem (Outlook.OlItem Type.olMailItem )

oItem.Subject = Subject
oItem.To = Recipient
oItem.Body = Body
oItem.BodyForma t = Outlook.OlBodyF ormat.olFormatR ichText

Dim bodyLength As String = oItem.Body.Leng th

Dim oAttachments As Outlook.Attachm ents = oItem.Attachmen ts
Dim oAttachment As Outlook.Attachm ent
oAttachment = oAttachments.Ad d(Filename, , bodyLength + 1, displayName)

oItem.Send()

oItem = Nothing
oApp = Nothing
End Sub
=== End Example ===

I got this code from someone else, and I have to admit I don't
really understand how the attachment part work, but that is another
issue. I had thought that adding the line with "olFormatRichTe xt"
would be sufficient to tell Outlook that the message body was RTF,
but clearly it isn't. I'm sure this is really simple, but I just
haven't been able to figure it out, so any help would be appreciated.
--
John Brock
jb****@panix.co m

--
John Brock
jb****@panix.co m

Nov 21 '05 #4
[Note: microsoft.publi c.outlook.progr am_vba was suggested as a good
forum for this question when I posted it elsewhere, but for some
reason my ISP doesn't carry that newgroup, and won't let me post
there, except as part of a cross-post, so my apologies to anyone
who sees this twice.]

I am currently using a VB.NET program to send out e-mails with
plain text bodies (plus one attachment). The emails are being
received as Rich Text messages (probably just my personal Outlook
default, because I didn't do this in the program), but there is no
actual formatting (italics, color, etc.) in the message body, which
is passed to from VB.NET to Outlook as an unformatted text String.

I want to start applying formatting to the message body. In
particular, my app has a RichTextBox, which has an Rtf property,
which returns a String formatted as RTF, which contains whatever
my users type or paste into the RichTextBox. That is what I want
to send as the body of the message.

Unfortunately all I get is garbage, like this:

{\rtf1\ansi\ans icpg1252\deff0\ deflang1033{\fo nttbl{\f0\froma n\fprq2\fcharse t0
Times New Roman;}{\f1\fni l\fcharset0 Microsoft Sans Serif;}}
{\colortbl ;\red255\green0 \blue0;}
\viewkind4\uc1\ pard\f0\fs24 This is \cf1 rich\cf0 \b\i text.\par
\b0\i0\par
\pard\f1\fs17\p ar
}

This is of course precisely the content of the input String,
formatting and all. Clearly I have failed to clue Outlook in that
the message body should be interpreted as RTF, not plain text. So
how should I do this?

Here is my code:

=== Begin Example ===
Imports Outlook = Microsoft.Offic e.Interop.Outlo ok

....

Sub MailerRoutine(B yVal Subject As String, ByVal Recipient As String, _
ByVal Body As String, ByVal Filename As String, ByVal displayName As String)

Dim oApp As Outlook.Applica tion = CreateObject("O utlook.Applicat ion")

Dim oItem As Outlook.MailIte m = oApp.CreateItem (Outlook.OlItem Type.olMailItem )

oItem.Subject = Subject
oItem.To = Recipient
oItem.Body = Body
oItem.BodyForma t = Outlook.OlBodyF ormat.olFormatR ichText

Dim bodyLength As String = oItem.Body.Leng th

Dim oAttachments As Outlook.Attachm ents = oItem.Attachmen ts
Dim oAttachment As Outlook.Attachm ent
oAttachment = oAttachments.Ad d(Filename, , bodyLength + 1, displayName)

oItem.Send()

oItem = Nothing
oApp = Nothing
End Sub
=== End Example ===

I got this code from someone else, and I have to admit I don't
really understand how the attachment part work, but that is another
issue. I had thought that adding the line with "olFormatRichTe xt"
would be sufficient to tell Outlook that the message body was RTF,
but clearly it isn't. I'm sure this is really simple, but I just
haven't been able to figure it out, so any help would be appreciated.
--
John Brock
jb****@panix.co m

Nov 21 '05 #5
Yes, that's exactly what I'm saying. The page I suggested describes your choices:

1) Redemption (easy, but third party)

2) CDO 1.21 and another helper .dll (CDO not being officially. supported in .NET languages, although I've heard of people using it)

3) If Word is the email editor, save the .rtf as a file, then open that file and copy paste text using Word objects. (Outlook exposes the Document for an email message through Inspector.WordE ditor.)

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx
"John Brock" <jb****@panix.c om> wrote in message news:dh******** **@reader1.pani x.com...
In article <#w************ **@tk2msftngp13 .phx.gbl>,
Sue Mosher [MVP-Outlook] <su****@outlook code.com> wrote:
The Outlook object model itself provides technique for creating an RTF message body. You can
set BodyFormat, but that just changes the message format. It doesn't give you a way to
actually get the RTF content into the message. To do that, the easiest approach is to use
the third-party Redemption library. See http://www.outlookcode.com/d/formatmsg.htm


I need this tomorrow, and I am afraid that third-party solutions
are out of the question in any case. Since I already have an RTF
formatted text string, are you saying there is no straightforward
way to insert it into an Outlook message? I would have assumed
that Microsoft would make this easy, since it seems like such a
natural thing to want to do, but then you never know with MS.
"John Brock" <jb****@panix.c om> wrote in message news:dh******** **@reader1.pani x.com...
I am currently using a VB.NET program to send out e-mails with
plain text bodies (plus one attachment). The emails are being
received as Rich Text messages (probably just my personal Outlook
default, because I didn't do this in the program), but there is no
actual formatting (italics, color, etc.) in the message body, which
is passed to from VB.NET to Outlook as an unformatted text String.

I want to start applying formatting to the message body. In
particular, my app has a RichTextBox, which has an Rtf property,
which returns a String formatted as RTF, which contains whatever
my users type or paste into the RichTextBox. That is what I want
to send as the body of the message.

Unfortunately all I get is garbage, like this:

{\rtf1\ansi\ans icpg1252\deff0\ deflang1033{\fo nttbl{\f0\froma n\fprq2\fcharse t0
Times New Roman;}{\f1\fni l\fcharset0 Microsoft Sans Serif;}}
{\colortbl ;\red255\green0 \blue0;}
\viewkind4\uc1\ pard\f0\fs24 This is \cf1 rich\cf0 \b\i text.\par
\b0\i0\par
\pard\f1\fs17\p ar
}

This is of course precisely the content of the input String,
formatting and all. Clearly I have failed to clue Outlook in that
the message body should be interpreted as RTF, not plain text. So
how should I do this?

Here is my code:

=== Begin Example ===
Imports Outlook = Microsoft.Offic e.Interop.Outlo ok

...

Sub MailerRoutine(B yVal Subject As String, ByVal Recipient As String, _
ByVal Body As String, ByVal Filename As String, ByVal displayName As String)

Dim oApp As Outlook.Applica tion = CreateObject("O utlook.Applicat ion")

Dim oItem As Outlook.MailIte m = oApp.CreateItem (Outlook.OlItem Type.olMailItem )

oItem.Subject = Subject
oItem.To = Recipient
oItem.Body = Body
oItem.BodyForma t = Outlook.OlBodyF ormat.olFormatR ichText

Dim bodyLength As String = oItem.Body.Leng th

Dim oAttachments As Outlook.Attachm ents = oItem.Attachmen ts
Dim oAttachment As Outlook.Attachm ent
oAttachment = oAttachments.Ad d(Filename, , bodyLength + 1, displayName)

oItem.Send()

oItem = Nothing
oApp = Nothing
End Sub
=== End Example ===

I got this code from someone else, and I have to admit I don't
really understand how the attachment part work, but that is another
issue. I had thought that adding the line with "olFormatRichTe xt"
would be sufficient to tell Outlook that the message body was RTF,
but clearly it isn't. I'm sure this is really simple, but I just
haven't been able to figure it out, so any help would be appreciated.
--
John Brock
jb****@panix.co m



--
John Brock
jb****@panix.co m

Nov 21 '05 #6
hi,
did you find any solution to your problem ?

I have the same problem with Word object automation.

Thanks in avance.

Roberto Garcia Martín

"John Brock" <jb****@panix.c om> escribió en el mensaje
news:dh******** **@reader1.pani x.com...
I am currently using a VB.NET program to send out e-mails with
plain text bodies (plus one attachment). The emails are being
received as Rich Text messages (probably just my personal Outlook
default, because I didn't do this in the program), but there is no
actual formatting (italics, color, etc.) in the message body, which
is passed to from VB.NET to Outlook as an unformatted text String.

I want to start applying formatting to the message body. In
particular, my app has a RichTextBox, which has an Rtf property,
which returns a String formatted as RTF, which contains whatever
my users type or paste into the RichTextBox. That is what I want
to send as the body of the message.

Unfortunately all I get is garbage, like this:

{\rtf1\ansi\ans icpg1252\deff0\ deflang1033{\fo nttbl{\f0\froma n\fprq2\fcharse t0
Times New Roman;}{\f1\fni l\fcharset0 Microsoft Sans Serif;}}
{\colortbl ;\red255\green0 \blue0;}
\viewkind4\uc1\ pard\f0\fs24 This is \cf1 rich\cf0 \b\i text.\par
\b0\i0\par
\pard\f1\fs17\p ar
}

This is of course precisely the content of the input String,
formatting and all. Clearly I have failed to clue Outlook in that
the message body should be interpreted as RTF, not plain text. So
how should I do this?

Here is my code:

=== Begin Example ===
Imports Outlook = Microsoft.Offic e.Interop.Outlo ok

...

Sub MailerRoutine(B yVal Subject As String, ByVal Recipient As String, _
ByVal Body As String, ByVal Filename As String, ByVal displayName As
String)

Dim oApp As Outlook.Applica tion = CreateObject("O utlook.Applicat ion")

Dim oItem As Outlook.MailIte m =
oApp.CreateItem (Outlook.OlItem Type.olMailItem )

oItem.Subject = Subject
oItem.To = Recipient
oItem.Body = Body
oItem.BodyForma t = Outlook.OlBodyF ormat.olFormatR ichText

Dim bodyLength As String = oItem.Body.Leng th

Dim oAttachments As Outlook.Attachm ents = oItem.Attachmen ts
Dim oAttachment As Outlook.Attachm ent
oAttachment = oAttachments.Ad d(Filename, , bodyLength + 1, displayName)

oItem.Send()

oItem = Nothing
oApp = Nothing
End Sub
=== End Example ===

I got this code from someone else, and I have to admit I don't
really understand how the attachment part work, but that is another
issue. I had thought that adding the line with "olFormatRichTe xt"
would be sufficient to tell Outlook that the message body was RTF,
but clearly it isn't. I'm sure this is really simple, but I just
haven't been able to figure it out, so any help would be appreciated.
--
John Brock
jb****@panix.co m

Nov 21 '05 #7
Roberto, I'd suggest that you describe your problem from scratch. It may not be the same as John's. Bottom line is that Outlook itself has no direct way to create RTF formatted messages. See http://www.outlookcode.com/d/formatmsg.htm
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx
"RgSystems" <rg*******@tele fonica.net> wrote in message news:uY******** ******@TK2MSFTN GP12.phx.gbl...
hi,


did you find any solution to your problem ?

I have the same problem with Word object automation.

Thanks in avance.

Roberto Garcia Martín

"John Brock" <jb****@panix.c om> escribió en el mensaje
news:dh******** **@reader1.pani x.com...
I am currently using a VB.NET program to send out e-mails with
plain text bodies (plus one attachment). The emails are being
received as Rich Text messages (probably just my personal Outlook
default, because I didn't do this in the program), but there is no
actual formatting (italics, color, etc.) in the message body, which
is passed to from VB.NET to Outlook as an unformatted text String.

I want to start applying formatting to the message body. In
particular, my app has a RichTextBox, which has an Rtf property,
which returns a String formatted as RTF, which contains whatever
my users type or paste into the RichTextBox. That is what I want
to send as the body of the message.

Unfortunately all I get is garbage, like this:

{\rtf1\ansi\ans icpg1252\deff0\ deflang1033{\fo nttbl{\f0\froma n\fprq2\fcharse t0
Times New Roman;}{\f1\fni l\fcharset0 Microsoft Sans Serif;}}
{\colortbl ;\red255\green0 \blue0;}
\viewkind4\uc1\ pard\f0\fs24 This is \cf1 rich\cf0 \b\i text.\par
\b0\i0\par
\pard\f1\fs17\p ar
}

This is of course precisely the content of the input String,
formatting and all. Clearly I have failed to clue Outlook in that
the message body should be interpreted as RTF, not plain text. So
how should I do this?

Here is my code:

=== Begin Example ===
Imports Outlook = Microsoft.Offic e.Interop.Outlo ok

...

Sub MailerRoutine(B yVal Subject As String, ByVal Recipient As String, _
ByVal Body As String, ByVal Filename As String, ByVal displayName As
String)

Dim oApp As Outlook.Applica tion = CreateObject("O utlook.Applicat ion")

Dim oItem As Outlook.MailIte m =
oApp.CreateItem (Outlook.OlItem Type.olMailItem )

oItem.Subject = Subject
oItem.To = Recipient
oItem.Body = Body
oItem.BodyForma t = Outlook.OlBodyF ormat.olFormatR ichText

Dim bodyLength As String = oItem.Body.Leng th

Dim oAttachments As Outlook.Attachm ents = oItem.Attachmen ts
Dim oAttachment As Outlook.Attachm ent
oAttachment = oAttachments.Ad d(Filename, , bodyLength + 1, displayName)

oItem.Send()

oItem = Nothing
oApp = Nothing
End Sub
=== End Example ===

I got this code from someone else, and I have to admit I don't
really understand how the attachment part work, but that is another
issue. I had thought that adding the line with "olFormatRichTe xt"
would be sufficient to tell Outlook that the message body was RTF,
but clearly it isn't. I'm sure this is really simple, but I just
haven't been able to figure it out, so any help would be appreciated.
--
John Brock
jb****@panix.co m


Nov 21 '05 #8
hi Sue,

all right, thak you very much for your answer.
I've put one message in at the top of this newsgroup.

Ref. "oRange.tex t = ?? "

thanks a lot.
Roberto Garcia Martin
Nov 21 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1774
by: Rolf Kemper | last post by:
Dear Experts, I want to send a formated query result by mail. I'm running SQL Server 2000 1) How can I achieve that the printed length of a field is based on the minimum required length to show the stored data uncut( Means the fieldlength is the maximum required length found in all items of a column ) ?
15
3315
by: Steve Horrillo | last post by:
I can't figure out why this script won't insert the subject in the email and why can't I control the font and size being used? I'm not sure where to post this. Let me know where if this is OT. <SCRIPT LANGUAGE="JavaScript"> <!-- Begin function isPPC() { if (navigator.appVersion.indexOf("PPC") != -1) return true; else return false;
4
2788
by: I'llGetItRightSoonerOrLater | last post by:
X-No-Archive: yes I need some help using Access to send a pre-formated e-mail message from my Outlook Drafts folder to a mailing list. At work I'm frequently asked to forward someone else's e-mail message to everyone on our e-mail mailing list. I manage the list using Access 2000 and found some VBA code online that automatically creates and sends an e-mail to every person in my list, one by one. But, my problem is the code I found...
6
3260
by: John J. Hughes II | last post by:
I have a service that needs to send e-mail alerts. I have been attempting to use the System.Net.Mail function from .NET but this seems to require the IIS be installed and running. Since some of my customers are not really happy with having the IIS installed, not being used except to send e-mail this is becoming a problem. I have also tried using a little program from code project for sending e-mail which works great on older servers...
3
3036
by: RN | last post by:
I am tired of sending mail from the built-in SMTP service for so many reasons (errors are nondescriptive in the event log, it doesn't let me control which IP address it sends from, and it identifies itself as the computer name which is not in domain.com format, triggering spam filter problems). Instead, I want to have my code send through an SMTP server of a company that we pay for mail service. But they require a username and password....
3
5378
by: sb Luis | last post by:
I Use the following code to read from MS Word, but I couldent read Formated Text (RTF). How Can I read formated text from MS Word Doc without using clipboard. thanks. Word.ApplicationClass WordApp = new Word.ApplicationClass(); ..... // Let's get the content from the document Word.Paragraphs DocPar = Doc.Paragraphs; // Count number of paragraphs in the file
14
9142
by: supz | last post by:
Hi, I use the standard code given below to send an email from an ASP.NET web form. The code executes fine but no Email is sent. All emails get queued in the Inetpub mail queue. I'm using my local default SMTP Server and my from address is a valid Yahoo/Hotmail address. I have configures the local SMTP Server to allow the IP Address 127.0.0.1.
0
8664
southoz
by: southoz | last post by:
Good ay all , I'm fairly new to access(a little over 5 weeks now). Since I'v started I have picked up a lot of useful information from forums such as this and in doing so will share that information with others. I have seen many request for information on mail merging an how to send data to word documents this is something I have put together with the answers given by others and I hope this will help a few newbies , I know there are easier ways...
4
7683
by: =?Utf-8?B?dHBhcmtzNjk=?= | last post by:
I have a web page that at the click of a button must send a bunch (1000+) emails. Each email is sent individually. I have the code working fine, using Mail Message classes and smtp and all that. But sometimes even when I'm just sending one e-mail the web page takes a minutes or so to post. Can anyone tell me why it is so slow, or how to fix the problem? To address this I am thinking of just creating a queue table to write the emails...
0
8984
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8823
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9530
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9312
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6793
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4593
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2775
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2206
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.