Hello cheddarthief,
Finally got this finished. Way too many phone calls this afternoon. This will check for either an HTML or plain text signature file. If both exist then the HTML version will be used.
'Written: April 07, 2010
'Updated: April 08, 2010
'Author: Leith Ross
'Summary: Email the ActiveSheet as an attachment using Outlook
Sub EmailSheetAsAttachment()
Dim BodyType As Integer
Dim FileName As String
Dim HtmlMsg As String
Dim olApp As Object
Dim shtName As String
Dim SigFile As String
Dim Signature As String
Dim SigPath As String
Dim TextMsg As String
Dim TextFile As Object
Dim WshShell As Object
TextMsg = "Please see the attached RFQ."
HtmlMsg = "<H3>" & TextMsg & "</H3>"
SigFile = "James J. Bender"
Set FSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = CreateObject("WScript.Shell")
SigPath = WshShell.SpecialFolders("Desktop")
SigPath = Left(SigPath, Len(SigPath) - 8) & "\Application Data\Microsoft\Signatures\"
SigFile = SigPath & SigFile
If Dir(SigFile & ".htm") <> "" Then
SigFile = SigFile & ".htm"
BodyType = 1
Else
If Dir(SigFile & ".txt") <> "" Then
SigFile = SigFile & ".txt"
BodyType = 0
Else
SigFile = ""
End If
End If
If SigFile <> "" Then
Set TextFile = FSO.OpenTextFile(SigFile, 1, False, -2)
Signature = TextFile.ReadAll
TextFile.Close
End If
shtName = ActiveSheet.Name
FileName = "RFQ-" & Range("C17") & "-Ref" & Range("C18")
ActiveSheet.Copy
ActiveWorkbook.SaveAs FileName
Set olApp = CreateObject("Outlook.Application")
With olApp.CreateItem(0)
.To = Range("C16")
.Subject = "Request for Quote-" & Range("C17") & "-Ref" & Range("C18")
Select Case BodyType
Case 0
.Body = TextMsg & vbCrLf & vbCrLf & Signature
Case 1
.HTMLBody = HtmlMsg & "<BR><BR>" & Signature
End Select
.Attachments.Add FileName, 1
.Display
End With
Cleanup:
ActiveWorkbook.Close False
Kill FileName
Set FSO = Nothing
Set WshShell = Nothing
End Sub
Bookmarks