LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Macro to Add More Than One HTM File to an Email

So right now this code will create an email then put a .htm file into
the body of the email. What I want to be able to do is have more than
one (maybe even three or four) .htm file(s) to be added to the body
(back to back to just look like a longer email). Does anyone know how
to do this? Or possibly have a better solution to my problem?

Thanks,

Tyson

============================

Sub SendEmail()
Dim OutApp As Object
Dim OutMail As Object
Dim body As String
Dim cell As Range
Dim strto As String
Dim subject As String


On Error Resume Next
For Each cell In ThisWorkbook.Sheets("Data Base") _
.Range("C5:C100").Cells.SpecialCells(xlCellTypeCon stants)
If cell.Value Like "?*@?*.?*" And LCase(cell.Offset(0,
-2).Value) = "yes" Then
strto = strto & cell.Value & ";"
End If
Next cell
On Error GoTo 0
If Len(strto) 0 Then strto = Left(strto, Len(strto) - 1)

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)

subject = Sheets("facts").Range("C15").Value & "-- " &
Sheets("facts").Range("C13").Value _
& " -- " & Sheets("facts").Range("C12").Value
attach = Sheets("facts").Range("C7").Value
attach2 = Sheets("facts").Range("C8").Value
attach3 = Sheets("facts").Range("C9").Value
attach4 = Sheets("facts").Range("C10").Value
attach5 = Sheets("facts").Range("C11").Value

On Error Resume Next
With OutMail
.To = ""
.CC = ""
.BCC = strto
.subject = subject
.htmlbody = Get_Body
.Attachments.Add attach
If attach2 < "" Then
.Attachments.Add attach2
If attach3 < "" Then
.Attachments.Add attach3
If attach4 < "" Then
.Attachments.Add attach4
If attach5 < "" Then
.Attachments.Add attach5
End If
End If
End If
End If
.Display
End With
On Error GoTo 0


Set OutMail = Nothing
Set OutApp = Nothing
End Sub

Function Get_Body() As String
Dim ie As Object, nav As String

nav = Sheets("facts").Range("C6").Value

Set ie = CreateObject("InternetExplorer.Application")
With ie
ie.Visible = False
ie.navigate nav
'.navigate "C:\test attachment.htm"
Do Until .ReadyState = 4
Loop
Get_Body = .Document.body.InnerHTML
.Quit

End With
Set ie = Nothing
End Function
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to disable my vba macro once I email out the file. Chris Excel Programming 3 April 18th 08 05:27 PM
Macro To Automate File Retrieval and Email carl Excel Programming 1 May 11th 07 09:59 PM
Problem with macro to email file using CDO AmyTaylor[_46_] Excel Programming 1 March 7th 06 01:43 PM
Save a file and send as an email - written into macro Louise Semaj Excel Programming 1 October 22nd 03 02:19 AM
Add shortcut instead of file to Email with Macro Richard Pieri Excel Programming 1 July 30th 03 04:15 PM


All times are GMT +1. The time now is 07:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"