Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SendMail Working but recieving an error

Status
Not open for further replies.

mpadgett

IS-IT--Management
Jun 24, 2005
57
US
Using the following code my workbook gets emailed to the appropriate recipients from a listbox but I get an error after execution. Any idea as to why? Thanks!

Code is:

Private Sub CommandButton4_Click()
Dim email_person
Dim entry_counter As Integer
entry_counter = -1

Do While entry_counter <= ListBox2.ListCount
entry_counter = entry_counter + 1
email_person = ListBox2.List(entry_counter, 0)
ActiveWorkbook.SendMail Recipients:=email_person, Subject:="Form 102 for Plate # " & Range("B1")

Loop

End Sub

Error is:

Run-time error '381':
Could not get the List property. Invalid property array index.
 
Do While entry_counter [!]<[/!] ListBox2.ListCount

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PH:

Thanks but using,

Do While entry_counter < ListBox2.ListCount

,still produced the same error message.

MP
 
And what about this ?
Private Sub CommandButton4_Click()
Dim email_person
Dim entry_counter As Integer
For entry_counter = 0 To ListBox2.ListCount - 1
email_person = ListBox2.List(entry_counter, 0)
ActiveWorkbook.SendMail Recipients:=email_person, Subject:="Form 102 for Plate # " & Range("B1")
Next
End Sub

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PH:

Eureka! Genius! It works perfectly!

Thank you very much,

Mp.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top