Sub ImportFromFileAndSend()
Dim objFSO As Object, _
objFile1 As Object, _
objFile2 As Object, _
olkMsg As Object, _
strBuffer As String, _
arrParts As Variant, _
strTable As String
Set objFSO = CreateObject("Scripting.FileSystemObject")
'On the next line edit the file name and path.'
Set objFile1 = objFSO.OpenTextFile("C:\eeTesting\masterfile.txt")
Do Until objFile1.AtEndOfStream
strBuffer = objFile1.ReadLine
arrParts = Split(strBuffer, ";")
Set olkMsg = Application.CreateItem(olMailItem)
With olkMsg
'On the next line edit the file path.'
Set objFile2 = objFSO.OpenTextFile("C:\eeTesting\" & arrParts(0))
'On the next line change the subject as desired.'
.Subject = "Your Subject Goes Here"
.To = arrParts(1)
.BodyFormat = olFormatHTML
Do Until objFile2.AtEndOfStream
'On the next line edit the HTML as desired.'
strTable = strTable & "<tr><td style=""background-color:#d0d0d0"">" & objFile2.ReadLine & "</td><td style=""background-color:#f0f0f0""> </td></tr>"
Loop
'On the next line edit the message as desired.'
.HTMLBody = "Hi,<br><br><table style=""width: 100%""><tr><td style=""background-color:#d0d0d0; width:50%""><b>Software Name</b></td><td style=""background-color:#f0f0f0; width:50%""><b>Comments</b></td></tr>" & strTable & "</table><br><br>Regards<br>Somename"
.Display
End With
objFile2.Close
Loop
Set olkMsg = Nothing
Set objFile1 = Nothing
Set objFile2 = Nothing
Set objFSO = Nothing
End Sub
|