.Attachments.Add "file path here",olByValue
I have not been able to find a way to attach the Word
document as the email body however. There must be a way to
do this since I can create the base email manually by
using Insert/File/As Text and then selecting the Word
document. I hope someone can help.
"TJ" <jke...@mccnh.com> wrote in message
news:349401c324a1$5082cd70$a001...@phx.gbl...
"Harold W Wood" <woody...@pacific.net.id> wrote in message news:ehFhIoKJ...@TK2MSFTNGP11.phx.gbl...
--
http://www.standards.com/; Howard Kaikow's web site.
------------------------------------------------
"TJ" <jke...@mccnh.com> wrote in message
news:004701c32856$e953fd40$a301...@phx.gbl...
first how to programatically save a word document in HTML format. This
should solve that problem.
-----------------------------------------------------------
Sub Save_Document(strPath As String, StrSep As String, StrName As
String)
Dim strWrk As String
Options.DefaultFilePath(wdDocumentsPath) = strPath
strWrk = "HTML Format Doc " & Trim(strName) & ".HTM"
ActiveDocument.SaveAs FileName:=strWrk, _
FileFormat:=wdFormatHTML, LockComments:=False, Password:="", _
AddToRecentFiles:=True, WritePassword:="",
ReadOnlyRecommended:=False, _
EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False,
SaveFormsData _
:=False, SaveAsAOCELetter:=False
End Sub
-----------------------------------------------------------
next problem is reading that into the body of an email message
-----------------------------------------------------------
Sub Create_Response(strWhoTo as string strName As String, Strletter As
String, intMenu as integer)
dim objtext as object
dim vartext as object
dim inptext as object
dim outItem as outlook.MailItem
Dim strSubject As String
Dim strBody As String
On Error Resume Next
Set objText = CreateObject("Scripting.FileSystemObject")
If Err <> 0 Then
'system error unable to create file system object
Beep
MsgBox "unable to create File System Object: " & Str(Err) _
& Chr(13) & Chr(10) _
& Err.Source _
& Chr(13) & Chr(10) _
& Err.Description, vbCritical, "SYSTEM ERROR"
UserForm_Terminate
Exit Sub
End If
Set varText = objText.getfile("C:\My Documents\LetterTexts\" & strName)
If Err <> 0 Then
'programmer error file not found
Beep
MsgBox "Unable to Locate Letter Text File: " & strName _
& " For user Option: " _
& Str(intMenu), vbCritical, "SYSTEM ERROR"
Set objText = Nothing
UserForm_Terminate
Exit Sub
End If
Set inpText = varText.openastextstream(1, -2)
If Err <> 0 Then
'programmer error file not found
Beep
MsgBox "Unable to read: " & strName _
& Chr(13) & Chr(10) _
& Err.Source _
& Chr(13) & Chr(10) _
& Err.Description, vbCritical, "SYSTEM ERROR"
Set objText = Nothing
Set varText = Nothing
UserForm_Terminate
Exit Sub
Else
bolFile = True
End If
strBody = inpText.readall
inpText.Close
' set up the reply and display it
With outItem
.Reply
.to=StrWhoTo
.Subject = strSubject
'The content of the document is used as the body for the email
.BodyFormat = olFormatHTML
.HTMLBody = strBody
' you can replace the .Display with a .Send at this point
' if you but sometimes i have to customize a little to
' answer specific questions
.Display
.FlagStatus = olNoFlag
End With
End Sub
hope that this helps.
woody
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
strbody = activedocument.range.select = wholestory
mailitem.body = strbody
====note==== this will remove formatting, to keep formatting save the word
document as web page and then use .bodyHTML instead of .body
"TJ" <jke...@mccnh.com> wrote in message
news:349401c324a1$5082cd70$a001...@phx.gbl...
>.
>
Function Create_Response(Optional strWhoTo As String,
Optional strName As String, Optional strSubject As String)
As Boolean
'strWhoTo is the email address, strName is the document
name, strSubject is the email subject line text
'**********************************************************
******
'* This code provided by Harold Wood
<woody...@pacific.net.id>
'* 6/10/2003 12:25:32 PM
'**********************************************************
******
Dim objText As Object 'variable to hold
Scripting.FileSystemObject
Dim varText As Object 'variable to hold the cover letter
document
Dim inpText As Object 'variable to hold the cover letter
document text
Dim myOutlookApp As Outlook.Application 'create a
reference to Outlook object
Dim newMessage As Outlook.mailItem 'create a reference to
a new email object
Dim strBody As String 'variable to hold the email body text
Dim newAtt As Outlook.Attachment 'create a reference to an
attachment object
Set myOutlookApp = New Outlook.Application
Set newMessage = myOutlookApp.CreateItem(olMailItem)
On Error Resume Next
Set objText = CreateObject("Scripting.FileSystemObject")
If Err <> 0 Then
'system error unable to create file system object
Beep
MsgBox "unable to create File System Object: " & Str
(Err) _
& Chr(13) & Chr(10) _
& Err.Source _
& Chr(13) & Chr(10) _
& Err.Description, vbCritical, "SYSTEM ERROR"
'UserForm_Terminate
Exit Function
End If
' Check if letter exists
Set varText = objText.getfile("H:\DTITrainPackageMay03\DTI
Email\e-mail cover letter 052803.htm")
If Err <> 0 Then
'programmer error file not found
Beep
MsgBox "Unable to Locate Letter Text File:" & strName _
& " For user Option: " _
& vbCritical, "SYSTEM ERROR"
Set objText = Nothing
'UserForm_Terminate
Exit Function
End If
' Open the letter as read only
Set inpText = varText.openastextstream(1, -2)
If Err <> 0 Then
'programmer error file not found
Beep
MsgBox "Unable to read: " & strName _
& Chr(13) & Chr(10) _
& Err.Source _
& Chr(13) & Chr(10) _
& Err.Description, vbCritical, "SYSTEM ERROR"
Set objText = Nothing
Set varText = Nothing
'UserForm_Terminate
Exit Function
'Else
'bolFile = True
End If
strBody = inpText.readall
inpText.Close
' set up the reply and display it
With newMessage
.Reply
.To = "jke...@mccnh.com " 'strWhoTo
.Subject = "strSubject"
'The content of the document is used as the body for
the email
'.BodyFormat = olFormatHTML
.HTMLBody = strBody
' you can replace the .Display with a .Send at this point
' if you want but sometimes i have to customize a little to
' answer specific questions
.Display
.FlagStatus = olNoFlag
End With
End Function
>.
>