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

Email from Excel with message text and attachment

Status
Not open for further replies.

Tiglet

Technical User
Apr 12, 2002
94
GB
I want to be able to send emails to specified recipients, with subject line, message and attachment. I have written the following macro which extracts data from an excel list and does all of the above except adding a message and I don't know how to.
Any ideas?
PS Running Novell Group Wise & Excel 97

Thanks

Sub Auto_email()
'
' Auto_email Macro
' Macro recorded 12/04/02


Dim strThisCC As String, strSheetName As String
Dim recipients As String, subject As String
Do While True
strThisCC = ActiveCell.Value
If strThisCC = "" Then Exit Sub
'If reaches end of list then stop macro
ActiveCell.Offset(0, 1).Activate
'move to next column which lists the recipients
recipient = ActiveCell.Value
ActiveCell.Offset(0, 1).Activate
'move to next column which lists the file names
subject = ActiveCell.Value
strSheetName = strThisCC & "_Budget2003.xls"
'open up next file
Workbooks.Open (strSheetName)
ActiveWorkbook.SendMail recipient, subject
ActiveWorkbook.Close
ActiveCell.Offset(1, -2).Activate
'go to next set of details on the list in excel
Loop
End Sub

 
You could use the RoutingSlip object as it has a message property. The following is copied from the vba help files

Workbooks("BOOK1.XLS").HasRoutingSlip = True
With Workbooks("BOOK1.XLS").RoutingSlip
.Delivery = xlOneAfterAnother 'or use xlAllAtOnce
.Recipients = Array("Adam Bendel", _
"Jean Selva", "Bernard Gabor")
.Subject = "Here is BOOK1.XLS"
.Message = "Here is the workbook. What do you think?"
End With
Workbooks("BOOK1.XLS").Route
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top