rebelgeek
New Member
- Joined
- Nov 23, 2008
- Messages
- 27
I have added a for/next to this code from a reference on the board. With out the for/next everything works. Add the for/next and it sends the first one only? What am I doing wrong?
Code:
Sub Mail_Text_From_Txtfile_Outlook()
' Is working in Office 2000-2007
Dim OutApp As Object
Dim OutMail As Object
Dim r As Long
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
For r = 2 To 4
Debug.Print r, Cells(r, 1)
With OutMail
.To = Cells(r, 1)
.CC = ""
.BCC = ""
.Subject = "This is the Subject line"
.Body = "Body text" ' GetBoiler("c:\test.txt")
.Send 'or use .Display
End With
Next r
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub