Thread: macro to email
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Mo Mo is offline
external usenet poster
 
Posts: 69
Default macro to email

I'm fairly new to VBE. I want to create a macro that emails sheets in a
workbook.
I am using a macro from Ron de Bruin of this community (his website). Here
is the problems I running into.

1-the sheets are not automatically emailed, I have to go into Outlook and
send. However, nothing is happening. I don't received the emails (I have a
Yahoo account).

2-The emails are not deleted after being send (I assume the macro does that).

I just want to be able to email the sheets once I click on the forms button.
I have enclosed the macro below.

Sub EmailReports()
Dim sh As Worksheet
Dim wb As Workbook
Dim strdate As String
Application.ScreenUpdating = False
For Each sh In ThisWorkbook.Worksheets
If sh.Range("m1").Value Like "?*@?*.?*" Then
strdate = Format(Now, "mm--dd--yy h-mm-ss")
sh.Copy
Set wb = ActiveWorkbook
With wb
.SaveAs "Sheet" & sh.Name & "of" _
& ThisWorkbook.Name & "" & strdate & ".xls"
.SendMail ActiveSheet.Range("m1").Value, _
"This is the Subject Line"
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
End If
Next sh
Application.ScreenUpdating = True
End Sub