I assume you know where you get your email address from.
The rest is straight COS and your code my look like this


set myEmail=.......      ;wherever you get it from your PID-13-4
set msg=..CreateTextMessage(myEmail)   
ClassMethod CreateTextMessage(toMail) As %Net.MailMessage
{
 Set msg = ##class(%Net.MailMessage).%New()
 Set msg.From = "test@test.com"
 Do msg.To.Insert(toMail)
 Do msg.Cc.Insert("yyy@yyy.com")
 Do msg.Bcc.Insert("zzz@zzz.com")
 Set msg.Subject="subject line here"
 Set msg.IsBinary=0
 Set msg.IsHTML=0
 Do msg.TextData.Write("This is the message.") 
 Quit msg
}

A dirty hack:

- make a new class extending %SerialObject with  VALIDIFNULL  set.
- export your serial classes (to XML)
- replace %SerialObject by your MySerialObject
- reload the changed classes.

Not so nice but I had the same issue with some 100 Serial Objects.

The more sophisticated way would be do it programatically over %Dictionary.DefinedProperty  ..... 
Very interesting and very time consuming  

Welcome back!

infile  ; simple file read
  set filename="C\mydir\myfile.txt"
  set $ZTRAP="end"
  open filename:("R"):0 else  Write "file error"
  for line=1:1 use filename read text use 0 write text,! 
end
 close filename
  set $ZTRAP=""
  use 0 write "Done",
  quit

it's not so sophisticated and I used the end-of-file error to exit

This is also available in class %Library.File with lot more comfort 
http://docs.intersystems.com/latest/csp/documatic/%25CSP.Documatic.cls?P...

HTH
 

If you don't want / need the content as object and just want to convert XML2JSON
why wasting time and energy to re-invent the wheel an not just using any of the many downloadable tools
and call them over $ZF(-2)  and consume the result ?
Google gave my some thousand hits of tested solutions e.g. https://github.com/sinelaw/xml-to-json

I mean it's doable with Caché but file_in => file_out is not more than a nice exercise for training.