Skip to content

Resending Outgoing Message followup to a new email address

Gareth Rees edited this page Sep 26, 2017 · 3 revisions

e.g. if the authority provides a separate internal review address that we don't have

# Replace with intended values
#
MESSAGE_ID = 0
EMAIL_ADDRESS = 'authority@example.com'
#
#

@outgoing_message = OutgoingMessage.find(MESSAGE_ID)

def @outgoing_message.to
  EMAIL_ADDRESS
end

@outgoing_message.prepare_message_for_resend

if @outgoing_message.sendable?
  mail_message = OutgoingMailer.followup(
    @outgoing_message.info_request,
    @outgoing_message,
    @outgoing_message.incoming_message_followup
  ).deliver_now

  @outgoing_message.record_email_delivery(
    mail_message.to_addrs.join(', '),
    mail_message.message_id,
    'resent'
  )
end
Clone this wiki locally