 |
|
|
|
| Author |
Message |
John Brock
Joined: 04 Oct 2007 Posts: 13
|
Posted: Sat Oct 01, 2005 4:10 am Post subject: 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\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\froman\fprq2\fcharset0
Times New Roman;}{\f1\fnil\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\par
}
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.Office.Interop.Outlook
....
Sub MailerRoutine(ByVal Subject As String, ByVal Recipient As String, _
ByVal Body As String, ByVal Filename As String, ByVal displayName As String)
Dim oApp As Outlook.Application = CreateObject("Outlook.Application")
Dim oItem As Outlook.MailItem = oApp.CreateItem(Outlook.OlItemType.olMailItem)
oItem.Subject = Subject
oItem.To = Recipient
oItem.Body = Body
oItem.BodyFormat = Outlook.OlBodyFormat.olFormatRichText
Dim bodyLength As String = oItem.Body.Length
Dim oAttachments As Outlook.Attachments = oItem.Attachments
Dim oAttachment As Outlook.Attachment
oAttachment = oAttachments.Add(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 "olFormatRichText"
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
jbrock@panix.com
Archived from group: microsoft>public>outlook>general |
|
| Back to top |
|
 |
Sue Mosher [MVP-Outlook]
Joined: 04 Oct 2007 Posts: 15
|
Posted: Sat Oct 01, 2005 6:07 am Post subject: Re: How do I send RTF formated mail using VB.NET? |
|
|
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.public.outlook.program_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" wrote in message $ebc$1@reader1.panix.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\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\froman\fprq2\fcharset0
> Times New Roman;}{\f1\fnil\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\par
> }
>
> 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.Office.Interop.Outlook
>
> ...
>
> Sub MailerRoutine(ByVal Subject As String, ByVal Recipient As String, _
> ByVal Body As String, ByVal Filename As String, ByVal displayName As String)
>
> Dim oApp As Outlook.Application = CreateObject("Outlook.Application")
>
> Dim oItem As Outlook.MailItem = oApp.CreateItem(Outlook.OlItemType.olMailItem)
>
> oItem.Subject = Subject
> oItem.To = Recipient
> oItem.Body = Body
> oItem.BodyFormat = Outlook.OlBodyFormat.olFormatRichText
>
> Dim bodyLength As String = oItem.Body.Length
>
> Dim oAttachments As Outlook.Attachments = oItem.Attachments
> Dim oAttachment As Outlook.Attachment
> oAttachment = oAttachments.Add(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 "olFormatRichText"
> 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
> jbrock@panix.com
> |
|
| Back to top |
|
 |
Mr Newbie
Joined: 04 Oct 2007 Posts: 1
|
Posted: Sat Oct 01, 2005 12:40 pm Post subject: Re: How do I send RTF formated mail using VB.NET? |
|
|
And who said newsgroups should not be used to promote one's business ?
"Sue Mosher [MVP-Outlook]" wrote in message
news:%23wAuMglxFHA.2960@tk2msftngp13.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.public.outlook.program_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" wrote in message $ebc$1@reader1.panix.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\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\froman\fprq2\fcharset0
> Times New Roman;}{\f1\fnil\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\par
> }
>
> 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.Office.Interop.Outlook
>
> ...
>
> Sub MailerRoutine(ByVal Subject As String, ByVal Recipient As String, _
> ByVal Body As String, ByVal Filename As String, ByVal displayName As
> String)
>
> Dim oApp As Outlook.Application = CreateObject("Outlook.Application")
>
> Dim oItem As Outlook.MailItem =
> oApp.CreateItem(Outlook.OlItemType.olMailItem)
>
> oItem.Subject = Subject
> oItem.To = Recipient
> oItem.Body = Body
> oItem.BodyFormat = Outlook.OlBodyFormat.olFormatRichText
>
> Dim bodyLength As String = oItem.Body.Length
>
> Dim oAttachments As Outlook.Attachments = oItem.Attachments
> Dim oAttachment As Outlook.Attachment
> oAttachment = oAttachments.Add(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 "olFormatRichText"
> 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
> jbrock@panix.com
> |
|
| Back to top |
|
 |
John Brock
Joined: 04 Oct 2007 Posts: 13
|
Posted: Sun Oct 02, 2005 9:50 pm Post subject: Re: How do I send RTF formated mail using VB.NET? |
|
|
In article ,
Sue Mosher [MVP-Outlook] 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.public.outlook.program_vba
Thanks, I'll give it a shot.
>"John Brock" wrote in message $ebc$1@reader1.panix.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\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\froman\fprq2\fcharset0
>> Times New Roman;}{\f1\fnil\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\par
>> }
>>
>> 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.Office.Interop.Outlook
>>
>> ...
>>
>> Sub MailerRoutine(ByVal Subject As String, ByVal Recipient As String, _
>> ByVal Body As String, ByVal Filename As String, ByVal displayName As String)
>>
>> Dim oApp As Outlook.Application = CreateObject("Outlook.Application")
>>
>> Dim oItem As Outlook.MailItem = oApp.CreateItem(Outlook.OlItemType.olMailItem)
>>
>> oItem.Subject = Subject
>> oItem.To = Recipient
>> oItem.Body = Body
>> oItem.BodyFormat = Outlook.OlBodyFormat.olFormatRichText
>>
>> Dim bodyLength As String = oItem.Body.Length
>>
>> Dim oAttachments As Outlook.Attachments = oItem.Attachments
>> Dim oAttachment As Outlook.Attachment
>> oAttachment = oAttachments.Add(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 "olFormatRichText"
>> 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
>> jbrock@panix.com
>>
--
John Brock
jbrock@panix.com |
|
| Back to top |
|
 |
Sue Mosher [MVP-Outlook]
Joined: 04 Oct 2007 Posts: 15
|
Posted: Mon Oct 03, 2005 4:39 am Post subject: Re: How do I send RTF formated mail using VB.NET? |
|
|
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.WordEditor.)
--
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" wrote in message $ga3$1@reader1.panix.com...
> In article ,
> Sue Mosher [MVP-Outlook] 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" wrote in message $ebc$1@reader1.panix.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\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\froman\fprq2\fcharset0
>>> Times New Roman;}{\f1\fnil\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\par
>>> }
>>>
>>> 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.Office.Interop.Outlook
>>>
>>> ...
>>>
>>> Sub MailerRoutine(ByVal Subject As String, ByVal Recipient As String, _
>>> ByVal Body As String, ByVal Filename As String, ByVal displayName As String)
>>>
>>> Dim oApp As Outlook.Application = CreateObject("Outlook.Application")
>>>
>>> Dim oItem As Outlook.MailItem = oApp.CreateItem(Outlook.OlItemType.olMailItem)
>>>
>>> oItem.Subject = Subject
>>> oItem.To = Recipient
>>> oItem.Body = Body
>>> oItem.BodyFormat = Outlook.OlBodyFormat.olFormatRichText
>>>
>>> Dim bodyLength As String = oItem.Body.Length
>>>
>>> Dim oAttachments As Outlook.Attachments = oItem.Attachments
>>> Dim oAttachment As Outlook.Attachment
>>> oAttachment = oAttachments.Add(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 "olFormatRichText"
>>> 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
>>> jbrock@panix.com
>>>
>
>
> --
> John Brock
> jbrock@panix.com
> |
|
| Back to top |
|
 |
RgSystems
Joined: 04 Oct 2007 Posts: 3
|
Posted: Thu Oct 06, 2005 2:00 pm Post subject: Re: How do I send RTF formated mail using VB.NET? |
|
|
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" escribió en el mensaje $ebc$1@reader1.panix.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\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\froman\fprq2\fcharset0
> Times New Roman;}{\f1\fnil\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\par
> }
>
> 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.Office.Interop.Outlook
>
> ...
>
> Sub MailerRoutine(ByVal Subject As String, ByVal Recipient As String, _
> ByVal Body As String, ByVal Filename As String, ByVal displayName As
> String)
>
> Dim oApp As Outlook.Application = CreateObject("Outlook.Application")
>
> Dim oItem As Outlook.MailItem =
> oApp.CreateItem(Outlook.OlItemType.olMailItem)
>
> oItem.Subject = Subject
> oItem.To = Recipient
> oItem.Body = Body
> oItem.BodyFormat = Outlook.OlBodyFormat.olFormatRichText
>
> Dim bodyLength As String = oItem.Body.Length
>
> Dim oAttachments As Outlook.Attachments = oItem.Attachments
> Dim oAttachment As Outlook.Attachment
> oAttachment = oAttachments.Add(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 "olFormatRichText"
> 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
> jbrock@panix.com
> |
|
| Back to top |
|
 |
Sue Mosher [MVP-Outlook]
Joined: 04 Oct 2007 Posts: 15
|
Posted: Thu Oct 06, 2005 12:36 pm Post subject: Re: How do I send RTF formated mail using VB.NET? |
|
|
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" wrote in message @TK2MSFTNGP12.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" escribió en el mensaje
> $ebc$1@reader1.panix.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\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\froman\fprq2\fcharset0
>> Times New Roman;}{\f1\fnil\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\par
>> }
>>
>> 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.Office.Interop.Outlook
>>
>> ...
>>
>> Sub MailerRoutine(ByVal Subject As String, ByVal Recipient As String, _
>> ByVal Body As String, ByVal Filename As String, ByVal displayName As
>> String)
>>
>> Dim oApp As Outlook.Application = CreateObject("Outlook.Application")
>>
>> Dim oItem As Outlook.MailItem =
>> oApp.CreateItem(Outlook.OlItemType.olMailItem)
>>
>> oItem.Subject = Subject
>> oItem.To = Recipient
>> oItem.Body = Body
>> oItem.BodyFormat = Outlook.OlBodyFormat.olFormatRichText
>>
>> Dim bodyLength As String = oItem.Body.Length
>>
>> Dim oAttachments As Outlook.Attachments = oItem.Attachments
>> Dim oAttachment As Outlook.Attachment
>> oAttachment = oAttachments.Add(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 "olFormatRichText"
>> 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
>> jbrock@panix.com
>>
>
> |
|
| Back to top |
|
 |
RgSystems
Joined: 04 Oct 2007 Posts: 3
|
Posted: Thu Oct 06, 2005 8:05 pm Post subject: Re: How do I send RTF formated mail using VB.NET? |
|
|
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.text = ?? "
thanks a lot.
Roberto Garcia Martin
|
|
| Back to top |
|
 |
|
|
| Related Topics: | Access to mail in Outlook via VB Peace! I have a big problem: I'm looking for a VB Code to have access to the mails in a subfolder of the archiv. For example, I would like to delete E-Mails depending of the subject and the received time. Can somebody help me? Many thanks! Stefan
Drag and drop mail from outlook to VB listview Hello, I want to drag and drop an email from outlook to a listview in my vb6 app. I'm only able to get the info using ole drag/drop. What I want is the same result when you drag and drop an email from outlook to explorer. When you drop it,
Hlelp, How to send a click event I wont to send a click to an external program sentind the coordinates. Is it possible? How to? Thanks, Ale Ps sorry for my orrible english ;)
Send Mail How Can I Send Mail via VB6.0 while my mail is i.e. To Yahoo Mail ? Thanks a lot
Send mail from VB6 What is the best (free) way to send mail from a VB6 program without using the standard mail components (MAPISession and thx, Bart |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|