If you didn't correct the other 2 mistakes it's no surprise.

The code should look like this:

 set tSC=$$$OK
 set ^tvalue=1
 set ^tvalue=$INCREMENT(^tvalue)
 
    #dim rs as EnsLib.SQL.GatewayResultSet
    #dim reStream as %Stream.GlobalCharacter
    if $$$ISERR(pRequest) quit pRequest
    set sc=..Adapter.ExecuteQuery(.rs,..GetTheSubmissionData(pRequest.pMonth, pRequest.pApp, pRequest.pRef, pRequest.pInPat))
   
    if $$$ISERR(sc) quit sc
  
   
set reStream=##class(%Stream.GlobalCharacter).%New()
    while rs.Next() {
        set (comma,rec)=""
        for i=1:1:rs.GetColumnCount() {
            set rec=rec_comma_""""_rs.GetData(i)_""""
            set comma=","   
        }
     ;;   set reStream=""   ;; dont kill your stream before using !!! OMG
        set sc=reStream.WriteLine(rec)
        
    }
    do reStream.%Save()

     ;; sc doesn't reflect if there is a content in reStream. check Size instead
   set sc=''reStream.Size

       
       if ($$$ISOK(sc))set pResponse.pReqDetails=reStream
           set reStream=""
        
else {$$$TRACE("There is nothing on the stream")
    
     set tSC=pResponse.%Save()
      
 set tSC=..SendRequestSync(..TargetConfigNames,pResponse,.pOutput)
 Quit tSC

 

Checking some hints for  SMTP.office365.com
https://answers.microsoft.com/en-us/msoffice/forum/msoffice_o365admin-mso_dep365/smtpoffice365com-relay-535-573-authentication/9de8d176-1c07-4e66-b14f-148d3bd51bbf

I see that the require SSL/TLS encryption.

In your code I miss
     Set server.SSLConfiguration = "whatever you named it

This might most likely cause the problem.
 

In anticipation of your next post:  How to setup SSL/TLS configuration.
http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=GCAS_ssltls#GCAS_ssltls_createedit
 

If DATA and CODE are separated then taking over CACHE.DAT from a final test environment could be an option.

But as the default for a namespace is DATA+CODE  and this is widely spread also in large applications in
real environments recompiling is the only possibility. Many years back even a special change was implemented in
Caché to support compiling during runtime of the code.

I personally dislike both and fought for clear separation of CODE from DATA. With very limited success.sad

I Googled just a few notes:
GE Healthcare to Acquire IDX Systems Corporation  (2005)
https://www.businesswire.com/news/home/20050929005340/en/GE-Healthcare-Acquire-IDX-Systems-Corporation-Significantly

and  wiki tells me it runs on Caché:
https://en.wikipedia.org/wiki/IDX_Systems

But this doesn't tell us how it communicates with users and external devices.
Caché is definitely not blocking a move to Linux. 
C++ based connections may prevent it if you don't have the sources and a lot of experience to test and debug it.
Eventually, other members of the developers' society have more detailed insight.

But I think GE should know it.

do you look for $System.Util.CreateGUID() ?
http://docs.intersystems.com/latest/csp/documatic/%25CSP.Documatic.cls?PAGE=CLASS&LIBRARY=%25SYS&CLASSNAME=%25SYSTEM.Util#METHOD_CreateGUID

Property myguid As %GUID Required ];

Will not work as %Lbrary.GUID is an abstract utility class and does not extend %DataType.  So it is no DataType and has no Accessors!
http://docs.intersystems.com/latest/csp/documatic/%25CSP.Documatic.cls?PAGE=CLASS&LIBRARY=%25SYS&CLASSNAME=%25Library.GUID

use instead.:

Property myguid As  %String  [Required];

and

S obj.myguid = $System. Util.CreateGUID()

But you are free to define your own data type combining %String and %GUID

there is an external config file in %cacheroot%/cache.cpf 
that holds your configuration. It is loaded at startup.
You can verify it with any text editor and check especially directories. of your DBs
And you see also NAMESPACE definitions.

The important part is at the beginning.

[ConfigFile]
Version=2017.226
[Databases]
CACHESYS=C:\InterSystems\17E20\mgr\
CACHELIB=C:\InterSystems\17E20\mgr\cachelib\
CACHETEMP=C:\InterSystems\17E20\mgr\cachetemp\
CACHE=C:\InterSystems\17E20\mgr\cache\
CACHEAUDIT=C:\InterSystems\17E20\mgr\cacheaudit\
BLOCKS=C:\opt\blocks\data\
DOCBOOK=C:\InterSystems\17E20\mgr\docbook\
ENSDEMO=C:\InterSystems\17E20\mgr\ensdemo\
ENSEMBLE=C:\InterSystems\17E20\mgr\ensemble\
ENSEMBLEENSTEMP=C:\InterSystems\17E20\mgr\ensemble\ensembleenstemp\
ENSEMBLESECONDARY=C:\InterSystems\17E20\mgr\ensemble\ensemblesecondary\
ENSLIB=C:\InterSystems\17E20\mgr\enslib\
SAMPLES=C:\InterSystems\17E20\mgr\samples\
TEST=C:\opt\blocks\test\
USER=C:\InterSystems\17E20\mgr\user\
[Namespaces]
%SYS=CACHESYS
BLOCKS=BLOCKS
DOCBOOK=DOCBOOK
ENSDEMO=ENSDEMO
ENSEMBLE=ENSEMBLE
SAMPLES=SAMPLES
USER=USER

 

IF it was really only permissions you could run ^SECURITY from terminal prompt

USER>zn "%SYS"
%SYS>d ^SECURITY

1) User setup
2) Role setup
3) Service setup
4) Resource setup
5) Application setup
6) Auditing setup
7) Domain setup
8) SSL configuration setup
9) Mobile phone service provider setup
10) OpenAM Identity Services setup
11) Encryption key setup
12) System parameter setup
13) X509 User setup
14) Exit
 
Option? 1
1) Create user
2) Edit user
3) List users
4) Detailed list users
5) Delete user
6) Export users
7) Import users
8) Exit
 
or   Option? 2
1) Create role
2) Edit role
3) List roles
4) Detailed list roles
5) Delete role
6) Export roles
7) Import roles
8) Exit
 
or   Option? 3
1) Edit service
2) List services
3) Detailed list services
4) Export services
5) Import services
6) Exit
 
Option? 4
Export which services? * => *
Export to file name ServicesExport.xml =>
and so on...

and Import on your test server .....

But take care how you handle external connections!