You want to know in your assembly the total mass of stainless steel parts, the total mass of HDPE parts, the total mass of steel parts... or have the mass of your assembly if it is made entirely of steel / stainless steel / HDPE ....????
1) Iterate on each of the components, based on this macro: https://forum.solidworks.com/thread/28710
2) Check what the material is: http://help.solidworks.com/2014/English/api/sldworksapi/get_and_set_material_visual_properties_example_vb.htm
3) Recover your volume: http://help.solidworks.com/2012/English/api/sldworksapi/SolidWorks.Interop.sldworks~SolidWorks.Interop.sldworks.IMassProperty~Volume.html
4) Create a total volume variable : For example, to assign a property: CODE = SWmoddoc.CustomInfo("code") More details on this link: http://www.lynkoa.com/forum/autres/vba-excel-pour-solidworks?page=0#answer-123844
5) Calculate the weight according to your volume for each material: With a simple calculation in VBA
6) Create a total weight variable for each material: see point 4)
In automatic I don't see but with a nomenclature it is quite simple and fast, we sort by materials and we add a line below each category of materials in which in calculation the sum of the masses above.