Ooogy
06-20-2007, 07:39 AM
I'm attempting to insert a Word document into the body of an email created by the Outlook mail object in an Excel worksheet. Essentially, the user clicks a name in the workbook and an email pops up with the contents of a shared Word doc as the body.
Having all sorts of problems with the mail object reading carriage returns as EOF markers, as well, it can't handle the bulleted list the document's author really wants to be included. I have experimented (successfully) with removing the carriage returns, replacing them with "~" in the original txt file, and then replacing the "~"'s with vbcrlf's once the object is fully read and into a string variable. Unfortunately, the formatting from the original text is all but gone using this method. Not good.
Can someone tell me in general terms what tree I should be barking up to to get this accomplished?
Here's what I'm using so far..
Dim sText As String
Dim sFile As String
Dim iFileNum As Integer
sFile = "M:\Reenroll_Tracking_Email.txt"
iFileNum = FreeFile
Open sFile For Input As iFileNum
Input #iFileNum, sText
Close #iFileNum
Dim oOApp As outlook.Application
Dim oOMail As outlook.MailItem
Set oOApp = CreateObject("Outlook.Application")
Set oOMail = oOApp.CreateItem(olMailItem)
With oOMail
.To = ActiveCell.Value
.Subject = "Email subject"
.Body = sText
.Display
End With
Set oOApp = Nothing
Set oOMail = Nothing
Thanks for any help at all!...Ooogy :banghead:
Having all sorts of problems with the mail object reading carriage returns as EOF markers, as well, it can't handle the bulleted list the document's author really wants to be included. I have experimented (successfully) with removing the carriage returns, replacing them with "~" in the original txt file, and then replacing the "~"'s with vbcrlf's once the object is fully read and into a string variable. Unfortunately, the formatting from the original text is all but gone using this method. Not good.
Can someone tell me in general terms what tree I should be barking up to to get this accomplished?
Here's what I'm using so far..
Dim sText As String
Dim sFile As String
Dim iFileNum As Integer
sFile = "M:\Reenroll_Tracking_Email.txt"
iFileNum = FreeFile
Open sFile For Input As iFileNum
Input #iFileNum, sText
Close #iFileNum
Dim oOApp As outlook.Application
Dim oOMail As outlook.MailItem
Set oOApp = CreateObject("Outlook.Application")
Set oOMail = oOApp.CreateItem(olMailItem)
With oOMail
.To = ActiveCell.Value
.Subject = "Email subject"
.Body = sText
.Display
End With
Set oOApp = Nothing
Set oOMail = Nothing
Thanks for any help at all!...Ooogy :banghead: