Exclude embedded images in email signature when saving attachments to M-Files

We're looking for a way to configure the M-Files Outlook Add-In to exclude embedded images in email signatures when using the Save attachments to M-Files option. This is primarily to avoid clutter from signature icons and other irrelevant inline images, which occasionally triggers duplicate detection.

I found an older post (Filtering Some Attachments in Outlook Add-In), but it doesn’t seem to have a working solution or registry key.

Is there any updated method, registry setting, or another possible solution?

Appreciate any guidance or recent experience you can share!

  • My advice would be to import mails to a special workflow which then has actions to either copy relevant attachments to new documents or delete irrelevant files from the multifile document created at import. Embedded images in signatures are typically small sized image files in .jpg or .png format. It should be fairly safe to delete any image files smaller than x KB. The details depend very much on the type of mails you receive. If e.g. the important attachment is always in PDF format you can simply create a new document for each PDF in the email and skip any other file types.

  • Could you provide an example vb script that we could use to delete .jpg/jpeg less than 5kb from a multi-file, because I am not having much luck

  • Found an old script in my archives (2017) designed to remove .msg files after import. It looks like something I may have gotten from Craig Hawker back in the day and possibly have modified myself. Anyways, you should be able to work from there. You can easily change the extension filter, and you can add a filter based on objFile.LogicalSizeEx as described in https://developer.m-files.com/APIs/COM-API/Reference/#MFilesAPI~ObjectFile_members.html

    Option Explicit
    ' script for EventHandler or WF Action, purpose to remove .msg file from multifile document after import of mail with attached document.
    ' the vault must include a boolean property with Alias "M-Files.Property.StripMsgFilesOnSave" and value = True 
    ' Should go in BeforeCheckInChangesFinalize Eventhandler or in WF Action script
    
    ' Declare the aliases that we will look up later.
    Const strStripMsgFilesOnSavePropertyAlias = "M-Files.Property.StripMsgFilesOnSave"
    
    ' Look up the aliases.
    Dim intStripMsgFilesOnSavePropertyId
    intStripMsgFilesOnSavePropertyId = Vault.PropertyDefOperations.GetPropertyDefIDByAlias("M-Files.Property.StripMsgFilesOnSave")
    
    ' Get the property values.
    Dim objPropertyValues
    Set objPropertyValues = Vault.ObjectPropertyOperations.GetProperties(ObjVer)
    
    ' Does the object have the "strip msg files" property?
    Dim objStripMsgFilesPropertyValue
    Set objStripMsgFilesPropertyValue = objPropertyValues.SearchForPropertyEx(intStripMsgFilesOnSavePropertyId, true)
    
    ' Only do this if it's a MFD and has the property.
    If Not (objStripMsgFilesPropertyValue Is Nothing) AND False = Vault.ObjectOperations.IsSingleFileObject(ObjVer) Then
    
    	' Only continue if it has the property and the value is true.
    	If (False = objStripMsgFilesPropertyValue.Value.IsEmpty() AND False = objStripMsgFilesPropertyValue.Value.IsNULL() AND objStripMsgFilesPropertyValue.Value.Value = true) Then
    		
    		' If it does then we need to deal with the files.
    		' Retrieve the files for this object version.
    			Dim objFile
    			Dim objFiles
    		Set objFiles = Vault.ObjectFileOperations.GetFilesForModificationInEventHandler(ObjVer)
    
    		' Iterate over the files and remove the msg ones.
    		Dim intRemainingFilesCount
    		intRemainingFilesCount = objFiles.Count
    
    		Dim intCount
    		For intCount = 1 To objFiles.Count
    			
    			' Get a reference to the file in the collection.
    			Set objFile = objFiles.Item(intCount)
    
    			' Ignore non-msg files.
    			If LCase(objFile.Extension & "") = "msg" Then
    
    				' Remove the msg file.
    				Vault.ObjectFileOperations.RemoveFile ObjVer, objFile.FileVer
    			
    				' Reduce the number of files remaining.
    				intRemainingFilesCount = intRemainingFilesCount - 1
    
    			End If
    
    		Next
    
    		' If the object only has one file remaining (and was not a SFD), set it to a SFD.
    		If (1 = intRemainingFilesCount) Then
    			Vault.ObjectOperations.SetSingleFileObject ObjVer, True
    		End If 
    		
    		' Remove the property.
    		Vault.ObjectPropertyOperations.RemoveProperty ObjVer, intStripMsgFilesOnSavePropertyId
    
    	End If
    
    End If

  • Thank you for the vb script, we are currently testing it with some alterations. fingers crossed