For problems like these you need to split the process into two (or more steps):
1) For steps where there is no phase change (e.g. no melting, freezing, boiling, etc.) and your substance is only changing temperature, you calculate the amount of heat absorbed/released as:
q = mCΔT
where q is the amount of heat, m is the mass of the substance, C is the specific heat capacity, and ΔT is the change in temperature.
2) For steps involving a phase change, you would use the following formula:
q = mΔH
where q is the amount of heat, m is the mass of the substance, and ΔH is the change in enthalpy associated with that particular phase change.