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 - Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

sending rtf,doc,text as message body in outllook 2003 in vb.net



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old March 27th 06, 02:17 AM posted to microsoft.public.outlook.program_forms
Digit Solver
external usenet poster
 
Posts: 2
Default sending rtf,doc,text as message body in outllook 2003 in vb.net

Hi,

I am trying to send a document using vb.net and outlook and words, The type
of file i would like to send are (rtf, doc, txt) as the message body in the
outlook message. Any one with experince in this area the help will be surely
appreciated.

I have added the code below i get some type of hresult type error when i run
this.





Public Sub SendDocMsg(ByVal subjectp As String, ByVal pEmail As String, _
ByVal fileDirLocation As String)

recipient = pEmail
subject = subjectp

Dim oLApp As Object
Dim oItem As Object
Dim oDoc As Object


On Error GoTo errorHandler


'Create a new mailitem
' oOutlook = New Outlook.Application
oLApp = CreateObject("Outlook.Application")
oItem = oLApp.CreateItem(0)
oDoc = CreateObject("Word.Application")
oDoc.Visible = True
oDoc.Documents.Open(fileDirLocation)


With oItem

'Set the recipient for the new email
.To = mRecipient

'Set the recipient for a copy
'.CC = "

'Set the subject
.Subject = mSubject

'The content of the document is used as the body for the email
.Body = oDoc.ActiveDocument.Content

.Send()
End With


errorHandler:
MsgBox(Err.Number & " " & Err.Description)
'Clean up
oItem = Nothing
oLApp = Nothing
oDoc = Nothing

End Sub ' SendMsg

--
Digit Solverâ„¢
Ads
  #2  
Old March 30th 06, 04:24 PM posted to microsoft.public.outlook.program_forms
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default sending rtf,doc,text as message body in outllook 2003 in vb.net

Body takes only a plain text string, no formatting. For an HTML message, set HTMLBody to the fully tagged HTML content, e.g. from an .htm file. For RTF, see http://www.outlookcode.com/d/formatmsg.htm for various options.

Do you also have Word 2003 installed?

--
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

"Digit Solver" wrote in message ...
Hi,

I am trying to send a document using vb.net and outlook and words, The type
of file i would like to send are (rtf, doc, txt) as the message body in the
outlook message. Any one with experince in this area the help will be surely
appreciated.

I have added the code below i get some type of hresult type error when i run
this.





Public Sub SendDocMsg(ByVal subjectp As String, ByVal pEmail As String, _
ByVal fileDirLocation As String)

recipient = pEmail
subject = subjectp

Dim oLApp As Object
Dim oItem As Object
Dim oDoc As Object


On Error GoTo errorHandler


'Create a new mailitem
' oOutlook = New Outlook.Application
oLApp = CreateObject("Outlook.Application")
oItem = oLApp.CreateItem(0)
oDoc = CreateObject("Word.Application")
oDoc.Visible = True
oDoc.Documents.Open(fileDirLocation)


With oItem

'Set the recipient for the new email
.To = mRecipient

'Set the recipient for a copy
'.CC = "

'Set the subject
.Subject = mSubject

'The content of the document is used as the body for the email
.Body = oDoc.ActiveDocument.Content

.Send()
End With


errorHandler:
MsgBox(Err.Number & " " & Err.Description)
'Clean up
oItem = Nothing
oLApp = Nothing
oDoc = Nothing

End Sub ' SendMsg

--
Digit Solverâ„¢

  #3  
Old March 30th 06, 07:03 PM posted to microsoft.public.outlook.program_forms
Digit Solver
external usenet poster
 
Posts: 2
Default sending rtf,doc,text as message body in outllook 2003 in vb.ne

Yes, i have words installed but when i used the oDoc.ActiveDocument.contents
i get a HRESULT error for some reason i don't know why.


--
Digit Solverâ„¢


"Sue Mosher [MVP-Outlook]" wrote:

Body takes only a plain text string, no formatting. For an HTML message, set HTMLBody to the fully tagged HTML content, e.g. from an .htm file. For RTF, see http://www.outlookcode.com/d/formatmsg.htm for various options.

Do you also have Word 2003 installed?

--
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

"Digit Solver" wrote in message ...
Hi,

I am trying to send a document using vb.net and outlook and words, The type
of file i would like to send are (rtf, doc, txt) as the message body in the
outlook message. Any one with experince in this area the help will be surely
appreciated.

I have added the code below i get some type of hresult type error when i run
this.





Public Sub SendDocMsg(ByVal subjectp As String, ByVal pEmail As String, _
ByVal fileDirLocation As String)

recipient = pEmail
subject = subjectp

Dim oLApp As Object
Dim oItem As Object
Dim oDoc As Object


On Error GoTo errorHandler


'Create a new mailitem
' oOutlook = New Outlook.Application
oLApp = CreateObject("Outlook.Application")
oItem = oLApp.CreateItem(0)
oDoc = CreateObject("Word.Application")
oDoc.Visible = True
oDoc.Documents.Open(fileDirLocation)


With oItem

'Set the recipient for the new email
.To = mRecipient

'Set the recipient for a copy
'.CC = "

'Set the subject
.Subject = mSubject

'The content of the document is used as the body for the email
.Body = oDoc.ActiveDocument.Content

.Send()
End With


errorHandler:
MsgBox(Err.Number & " " & Err.Description)
'Clean up
oItem = Nothing
oLApp = Nothing
oDoc = Nothing

End Sub ' SendMsg

--
Digit Solverâ„¢


  #4  
Old March 31st 06, 04:37 PM posted to microsoft.public.outlook.program_forms
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default sending rtf,doc,text as message body in outllook 2003 in vb.ne

Here's a better way to create a message with the Word document contents as the message body:

Dim env as Office.MsoEnvelope = oDoc.ActiveDocument.MailEnvelope
Dim oItem as Outlook.MailItem
oItem = CType(env.Item, Outlook.MailItem)
With oItem
'Set the recipient for the new email
.To = mRecipient

'Set the recipient for a copy
.CC = "

'Set the subject
.Subject = mSubject

' next statement will trigger security prompt
.Send()
End With

The message format will always be HTML automatically.
--
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

"Digit Solver" wrote in message ...
Yes, i have words installed but when i used the oDoc.ActiveDocument.contents
i get a HRESULT error for some reason i don't know why.


--
Digit Solverâ„¢


"Sue Mosher [MVP-Outlook]" wrote:

Body takes only a plain text string, no formatting. For an HTML message, set HTMLBody to the fully tagged HTML content, e.g. from an ..htm file. For RTF, see http://www.outlookcode.com/d/formatmsg.htm for various options.

Do you also have Word 2003 installed?

"Digit Solver" wrote in message ...
Hi,

I am trying to send a document using vb.net and outlook and words, The type
of file i would like to send are (rtf, doc, txt) as the message body in the
outlook message. Any one with experince in this area the help will be surely
appreciated.

I have added the code below i get some type of hresult type error when i run
this.





Public Sub SendDocMsg(ByVal subjectp As String, ByVal pEmail As String, _
ByVal fileDirLocation As String)

recipient = pEmail
subject = subjectp

Dim oLApp As Object
Dim oItem As Object
Dim oDoc As Object


On Error GoTo errorHandler


'Create a new mailitem
' oOutlook = New Outlook.Application
oLApp = CreateObject("Outlook.Application")
oItem = oLApp.CreateItem(0)
oDoc = CreateObject("Word.Application")
oDoc.Visible = True
oDoc.Documents.Open(fileDirLocation)


With oItem

'Set the recipient for the new email
.To = mRecipient

'Set the recipient for a copy
'.CC = "

'Set the subject
.Subject = mSubject

'The content of the document is used as the body for the email
.Body = oDoc.ActiveDocument.Content

.Send()
End With


errorHandler:
MsgBox(Err.Number & " " & Err.Description)
'Clean up
oItem = Nothing
oLApp = Nothing
oDoc = Nothing

End Sub ' SendMsg

--
Digit Solverâ„¢


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
Sending email via .NET msnews.microsoft.com Outlook - General Queries 7 March 18th 06 07:12 PM
Outlook won't display body of plain text message Mike Outlook - General Queries 1 March 14th 06 07:54 PM
Doc Message Class and MS Server 2003/OL2003 Stimpy Outlook - Using Forms 1 March 13th 06 01:21 AM
need to send rtf format using smtp and vb6 or vb.net aharbour Outlook and VBA 1 February 21st 06 02:56 PM
Embed an image in rtf doc (appointment or email body) Sue Mosher [MVP-Outlook] Outlook and VBA 0 February 1st 06 05:20 PM


All times are GMT +1. The time now is 08:53 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.