Sub CopyCellAsImageAndEmail()
Dim rng As Range
Dim ws As Worksheet
Dim filePath As String
Dim emailApp As Object
Dim emailItem As Object
' Reference the specific worksheet and cell
Set ws = ThisWorkbook.Sheets("Raw")
Set rng = ws.Range("M2")
' Copy the cell as a picture
rng.CopyPicture Appearance:=xlScreen, Format:=xlPicture
' Create a temporary file path
filePath = Environ("TEMP") & "\CellImage.jpg"
' Create a new chart to hold the picture
Dim chartObj As ChartObject
Set chartObj = ws.ChartObjects.Add(Left:=rng.Left, Top:=rng.Top, Width:=rng.Width, Height:=rng.Height)
chartObj.Chart.Paste
chartObj.Chart.Export Filename:=filePath, FilterName:="JPG"
chartObj.Delete
' Create the email
Set emailApp = CreateObject("Outlook.Application")
Set emailItem = emailApp.CreateItem(0)
With emailItem
.To = "recipient@example.com"
.Subject = "Cell Image"
' Use HTMLBody to embed the image
.HTMLBody = "<html><body>" & _
"Please find the image below:<br><br>" & _
"<img src='cid:CellImage'><br><br>" & _
"Best regards,<br>Your Name</body></html>"
' Attach the image as a linked resource
.Attachments.Add filePath, 1, 0, "CellImage"
.Display ' Use .Send to send the email directly
End With
' Clean up
Set emailItem = Nothing
Set emailApp = Nothing
End Sub