Can anyone help with E-mail macro
Posted by Lewis (1) on December 16, 2001 6:14 AM
Hi
Robb was kind enough to give me the following
Sub SendSheet()
Dim myFile As String, s As String
'Copy the sheet to a new workbook ready to mail
ThisWorkbook.ActiveSheet.Copy
'Identify the new book
myFile = ActiveWorkbook.Name
ThisWorkbook.Activate
'Open mail session if not already open
If Not IsNull(Application.MailSession) Then Application.MailLogon
'Identify the sheet containing the mail addresses
With ThisWorkbook.Worksheets("Sheet1").Cells
'Target the cells containing the addresses
For Each c In .Range("B1:B4").Cells
'Ensure the addresses are read as text
s = c.Value
'Mail the document
Workbooks(myFile).SendMail Recipients:=s, Subject:="Here is the sheet", ReturnReceipt:=True
Next c
End With
'Close the temp file without saving
Workbooks(myFile).Close savechanges:=False
End Sub
This copies the active sheet opens a new workbook and sends the info as an attachment Book1.xls etc.
Can anyone claify if it is necessary to open a new workbook? or can you send the page directly
Is it possible to send the page in the body of the message, with or without opening a new workbook
Regards
Lewis