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 Command

Status
Not open for further replies.

mpadgett

IS-IT--Management
Jun 24, 2005
57
US
I'm using the following code to email the Active Workbook with email_person as a variable. I 'm getting an error and the email is unsuccessful. Any suggestions?

ActiveWorkbook.SendMail Recipients:=email_person

 
Which error message ?
What is the value of email_person ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Before you blame your code do check that you can manually send an email to that address. It could be that the adddress is not correct or your mailbox could be full. Outlook will guess at an incomplete name, I believe but sendmail is more fussy.

I have an error handler wrapped around my sendto line to send any failure to a default address - mine). If that generates an error then so far it has always meant that my mailbox is too full - very tricky if half-way through my email loop.



Gavin
 
Okay, I've discovered that my challenge isn't the emailing part.
I've got a ListBox that the user populates with names that he wants to email the WorkBook to. I'm having difficulty extracting those names from the ListBox and assigning them to the email_person variable. I was trying to use a Do While Loop to cycle through the list box and and get the names using ListCount to determine the number of times.
Any suggestions would be very appreciated.
Mike P.
 
Not familar with ListBoxes. Where do the addresses end up? In an array? In cells on the spreadsheet or what?

I have a routine that looks in a specific cell in the worksheet. That cell contains an email address or more than one with a ; separator. The requisite sheet is then emailed to that address.

You should post the code that you are using.


Gavin
 
Don't to a Do While loop, just loop through the number of items in the listbox. Here is an example...

Code:
Private Sub cmbMessage_Click()
    Dim i As Long, strMsg As String
    For i = 0 To Me.lbAddy.ListCount - 1
        strMsg = strMsg & Me.lbAddy.List(i) & "; "
    Next i
    strMsg = Left(strMsg, Len(strMsg) - 2)
    MsgBox strMsg, vbInformation
End Sub

My Listbox was named lbAddy.

HTH

Regards,
Zack Barresse

Simplicity is the ultimate sophistication. What is a MS MVP? PODA
- Leonardo da Vinci
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top