Contrast-enhanced spectral mammography (CESM) has proven to be a beneficial tool for additional management and diagnosis of breast cancer in patients. Deep learning-based automated tools for analyzing CESM images and detecting abnormalities can be crucial in reducing the workload of radiologists. Even though self-supervised learning (SSL) can significantly influence the quality of learned representations resulting in increased classification performances, it requires large amounts of data often unavailable in the CESM domain. In this work, we propose a novel loss function named Difficulty-Weighted Neighborhood Representation (DWNR) utilizing the SSL-based representations designed explicitly for the downstream classification of the region of interest (ROI) in CESM images in a small dataset setting. We propose utilizing the neighborhood representations extracted from an SSL backbone to guide the loss function in learning robust representations of the dataset's normal, benign, and malignant ROIs. We formulate the DWNR loss using a combination of a neighborhood representation-guided triplet (NR-triplet) loss and a difficulty-weighted cross-entropy (DWCE) loss. The NR-triplet loss leverages the nearest and farthest neighbor feature representations, extracted from a self-supervised backbone, as positive and negative samples. Meanwhile, the DWCE loss exploits the class information from the nearest neighbors to perform per-sample difficulty weighting. The experimental results on the publicly available CDD-CESM dataset demonstrate that the proposed DWNR loss outperforms traditional loss functions such as Cross-Entropy (CE) and Focal loss by a significant gain of more than 2% absolute mean F1-scores for both SSL-based and ImageNet-SSL-based transfer learning. In addition, we demonstrate the efficacy of employing a DWNR-based ROI classifier for comprehensive CESM whole image analysis in BI-RADS scoring and cancer diagnosis. The results reveal a gain in mean F1-scores of more than 1% in both tasks when using the DWNR loss models for CNN initialization, indicating the significance of the proposed method to whole image analysis. Based on our analysis, incorporating DWNR loss during transfer learning could positively impact automated breast cancer diagnosis using the CESM imaging modality. This novel loss function opens new possibilities for leveraging deep learning in CESM, particularly in scenarios with limited labeled data availability.