I need help to modify this macro to send all sheets from the same workbook separately in one email.
VBA Code:
Sub SendemailAll()
Dim xOutlookObj As Object
Dim xEmailObj As Object
Dim tempFile As String
Dim strbodymsg As String
Dim wb As Workbook
Dim strbody As String
Dim tempWB As Workbook
Dim DisplayEmail As String, Signature As String
Dim a, b, c, d As String
Application.DisplayAlerts = False
ThisWorkbook.Sheets.Copy
Set tempWB = ActiveWorkbook
tempWB.SaveAs Filename:="All sheets"
'problem how to separate save all sheets
'variable from userform or string outputs into default documents folder as xls
'Create Outlook email=============
Set xOutlookObj = CreateObject("Outlook.Application")
Set xEmailObj = xOutlookObj.CreateItem(0)
With xEmailObj
.Display
End With
Signature = xEmailObj.Body
On Error Resume Next
With xEmailObj
a = ThisWorkbook.Sheets("Sheet1").Range("R1").Value
b = ThisWorkbook.Sheets("Sheet1").Range("R2").Value
c = ThisWorkbook.Sheets("Sheet1").Range("R3").Value
d = ThisWorkbook.Sheets("Sheet1").Range("R4").Value
.Display
.To = a
.CC = b
.Subject = c
.Attachments.Add tempWB.FullName
'previously saved workbook with single sheet
.Body = d & Signature
If DisplayEmail = False Then
'.Display
'.Send
End If
End With
tempWB.ChangeFileAccess Mode:=xlReadOnly
Kill tempWB.FullName
tempWB.Close SaveChanges:=False
Application.DisplayAlerts = True
Set xEmailObj = Nothing
Set xOutlookObj = Nothing
End Sub