Macro to email a spastic page to addresses in the workbook

Dave8899

New Member
Joined
Jan 17, 2019
Messages
32
Hi sorry if this is already on her but I've been looking for 3 days now and cant find the answer.

I have the following VBA that will send a email to the address in the workbook But i need it to only send one spastic sheet names Time.
as a new book single sheet or a PDf what ever works


Sub EmailAttachmentRecipients()


ActiveSheet.Unprotect Password:="123"




Dim objOutlook As Object
Dim objNameSpace As Object
Dim objInbox As Object
Dim objMailItem As Object
Set objOutlook = CreateObject("Outlook.Application")
Set objNameSpace = objOutlook.GetNamespace("MAPI")
Set objInbox = objNameSpace.Folders(1)
Set objMailItem = objOutlook.CreateItem(0)


Dim StrTo As String
Dim i As Integer
StrTo = ""
i = 1


With Worksheets("Email")
Do
StrTo = StrTo & .Cells(i, 1).Value & "; "
i = i + 1
Loop Until IsEmpty(.Cells(i, 1))
End With


StrTo = Mid(StrTo, 1, Len(StrTo) - 2)


With objMailItem
.To = StrTo
.CC = ""
.Subject = "Time sheet for " & Format(Sheets("Email").Range("n2")) & Format(Sheets("Email").Range("L2"))
.Body = _
"Hi," & Chr(10) & Chr(10) & _
"Please see attached Time sheet for the above individual" & Chr(10) & _
""
.Attachments.Add ActiveWorkbook.FullName
.Display
End With




Set objOutlook = Nothing
Set objNameSpace = Nothing
Set objInbox = Nothing
Set objMailItem = Nothing


ActiveSheet.Protect Password:="123"


End Sub
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Forum statistics

Threads
1,224,828
Messages
6,181,201
Members
453,022
Latest member
RobertV1609

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top