View Single Post
 
Old 11-17-2015, 05:43 AM
gmayor's Avatar
gmayor gmayor is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,142
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Easy? You can use check whether there is a message attachment with a name like "image*.*" as messages with images will treat those images as attachments. The following function will establish whether the current message has such an image:

Code:
Sub ProcessMessage()
'An Outlook macro by Graham Mayor
Dim olMsg As MailItem
    On Error Resume Next
    Set olMsg = ActiveExplorer.Selection.Item(1)
    MsgBox HasPicture(olMsg)
lbl_Exit:
    Exit Sub
End Sub

Private Function HasPicture(olItem As MailItem) As Boolean
'An Outlook macro by Graham Mayor
Dim olAttach As Attachment
Dim strExt As String
Dim j As Long
    On Error GoTo lbl_Exit
    If olItem.Attachments.Count > 0 Then
        For j = olItem.Attachments.Count To 1 Step -1
            Set olAttach = olItem.Attachments(j)
            If olAttach.FileName Like "image*.*" Then
                HasPicture = True
                Exit For
            End If
        Next j
        olItem.Save
    End If
lbl_Exit:
    Set olAttach = Nothing
    Set olItem = Nothing
    Exit Function
End Function
You can call it from a macro to check individual messages (as above) or loop through a selection or folder full of messages
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote