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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel issue

Status
Not open for further replies.

Audissimo

Technical User
Oct 12, 2005
5
FI
Hello.

I have a excel sheet and there is some company names with postal codes and e-mail addresses. Now, I need to send a reports to those companies. The problem is, if a e-mail address found, then report should send via e-mail. The e-mail can be found two columns. First the Column C should be cheked and then Column B. How can I do it?

Column A Column B Column C Column D
Company 1 e-mail 1 e-mail 2 Postal Code
Company 2
.
.
.
Company 100


-JK
 
Assumuing you name the 2 column range containing the email addresses "emails" then:
Code:
'sendEmail = False          'Disables sending of emails
For Each r In Range("emails")
sendto = r.Value
EmailTitle = "Report for " + r.offset(0,-1).Value
        
'need to trap invalid email addresses
On Error GoTo ErrorHandler
If SendEmail Then ActiveWorkbook.sendmail Recipients:=sendto, Subject:=EmailTitle, RETURNRECEIPT:=True
On Error GoTo 0
Next r

ErrorHandler:
r.Offset(0, 3).Value = "email failure " + r.Value
Resume
Note you can get an email failure if your mailbox is too full.
Test the routine with your pc offline so you can delete the test emails from your outbox.
You will need to something to handle the cell cell being blank.



Gavin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top