A search is performed for the electroweak pair production of charginos and associated production of a chargino and neutralino, each of which decays through an R-parity-violating coupling into a lepton and a W, Z, or Higgs boson. The trilepton invariant-mass spectrum is constructed from events with three or more leptons, targeting chargino decays that include an electron or muon and a leptonically decaying Z boson. The analyzed dataset corresponds to an integrated luminosity of 139 fb-1 of proton-proton collision data produced by the Large Hadron Collider at a center-of-mass energy of s=13 TeV and collected by the ATLAS experiment between 2015 and 2018. The data are found to be consistent with predictions from the Standard Model. The results are interpreted as limits at 95% confidence level on model-independent cross sections for processes beyond the Standard Model. Limits are also set on the production of charginos and neutralinos for a minimal supersymmetric Standard Model with an approximate B-L symmetry. Charginos and neutralinos with masses between 100 and 1100 GeV are excluded depending on the assumed decay branching fractions into a lepton (electron, muon, or τ lepton) plus a boson (W, Z, or Higgs). © 2021 CERN.