Creating sub
Sub DispoSendEmail()
variables created
Dim olApp As Outlook.Application
Dim olEmail As Outlook.MailItem
Set olApp = New Outlook.Application
Dim rng As Range
Set rng = Range("b2:h46")
Dim rng2 As Range
Set rng2 = Range("l2:r46")
Dim TempFilePath As String
TempFilePath = Environ$("temp") & "\"
email object created
Set olEmail = olApp.CreateItem(olMailItem)
calling screenshot function
Call createJpg("Sheet2", rng.Address, "Before")
Call createJpg("Sheet2", rng2.Address, "After")
With olEmail
.To = "e"
.CC = "abc"
.Attachments.Add TempFilePath & "Before.jpg", olByValue
.Attachments.Add TempFilePath & "After.jpg", olByValue
' .To = " "
.Subject = Sheets("SINGLE SELL SUMMARY").Range("O2")
Problem 1, error on sheets.
.HTMLBody = "Hey Tom," & "<br>" & "<br>" Sheets.
("Email_Sheet").Range("F6") & "<br>" & "<br>" &
Problem 2 here on sheets
Sheet1.email_body.Text & "<br><img src='cid:Before.jpg'>" &
Image here
"<img src='cid:After.jpg'>" & "Warm Regards," & "<br>"
.Display
End With
Ending sub
End Sub
Sub creating the method to screen shot range
Sub createJpg(SheetName As String, xRgAddrss As String, nameFile As String)
Dim xRgPic As Range
ThisWorkbook.Activate
Worksheets(SheetName).Activate
Set xRgPic = ThisWorkbook.Worksheets(SheetName).Range(xRgAddrss)
xRgPic.CopyPicture
With ThisWorkbook.Worksheets(SheetName).ChartObjects.Add(xRgPic.Left, xRgPic.Top, xRgPic.Width, xRgPic.Height)
.Activate
.Chart.Paste
.Chart.Export Environ$("temp") & "\" & nameFile & ".jpg", "JPG"
End With
Worksheets(SheetName).ChartObjects(Worksheets(SheetName).ChartObjects.Count).Delete
Set xRgPic = Nothing
End Sub
Comments
Post a Comment