e.g. I can normally achieve this. with the below code:

'Rectangle 40 - Auto email & change shape fill

Sub SendMailAndChangeImageR40()

   Dim outapp As Object
   Dim outmail As Object
On Error Resume Next
Err.Clear
Set outapp = GetObject(class:="outlook.application")
If Err <> 0 Then Set outapp = CreateObject("outlook.application")
outapp.session.logon
Set outmail = outapp.createitem(0)

On Error Resume Next
If ActiveSheet.Shapes("rectangle 40").Fill.ForeColor.RGB = RGB(255, 255, 255) Then
With outmail
.To = ""
.CC = ""
.BCC = ""
.Subject = ""
.Body = ""
.Send
End With

Set outapp = Nothing
Set outmail = Nothing

End If

End Sub
but this doesn't seem to work anymore when I include more code. I also need the shape to change from displaying an image - to going back to a white fill.


the code I use for that, is this:

sub changefill()

Dim shp As Shape
Set shp = ActiveSheet.Shapes("rectangle 40")
With shp.Fill
.Visible = msoTrue
If .Type = msoFillPicture Then
.Solid
Else
.UserPicture "C:\Users\boymam\Desktop\Graphics\tick.jpg"
End If
End With

end sub

but when I ADD that into the top OR bottom of my email code. to blend as one.. it sends the email even when the fill has changed to the image.

I want the email to ONLY send when the shape is WHITE. when the shape is my image - I don't want it to send when I click etc.