ClassMethod SendMAil(mail As %Library.String, Url As %Library.String) As %Status
{

 Set server=##class(%Net.SMTP).%New()
 
  Set server.smtpserver="smtp.office365.com"
  //HotPOP SMTP server uses the default port (25)
  Set server.port=25
 
  //Create object to carry authentication

  Set auth=##class(%Net.Authenticator).%New()
  Set auth.UserName="noreply-service@*********.com"
  Set auth.Password="************"
 
  Set server.authenticator=auth
  Set server.AuthFrom=auth.UserName
 
 //create smtp server instance
 
 //generate mail body
 Set msg = ##class(%Net.MailMessage).%New()
 Set msg.From=server.authenticator.UserName
  Do msg.To.Insert(mail)
 Set msg.Subject="Set New Password"_$H
 Set msg.IsBinary=0
 Set msg.IsHTML=0
 Do msg.TextData.Write(Url)
 set status= server.Send(msg)
  If $$$ISERR(status) {
    Do $System.Status.DisplayError(status)
    Write server.Error
    
    Quit ""
  }
 
  Quit server.FailedSend
 

}

**********************************************************************

on my poste man i've this error: ERROR #6034 connetion failed to the SMTP server

here an example of my request , it can help you:

 

method CheckMissedMeasure() As %Status
{

 //selectionner tous les patients en retard  
 set myquery=3
 set myquery(1) = "SELECT profile_id,Type_Measure, Program as Heure_Ratée,Practitioner_Id,Warning_Type FROM Bwxpert_Repository.Enrollment" // enrollment
 set myquery(2) = " where GETDATE()>NEXT_MEASURE"
 set myquery(3)="and Alert=0"
  set tStatement = ##class(%SQL.Statement).%New()
 set qStatus = tStatement.%Prepare(.myquery)
  if qStatus'=1 {WRITE "%Prepare failed:" DO $System.Status.DisplayError(qStatus) QUIT}
    
  set rset = tStatement.%Execute()
     set array = []
     set json ={}
     while rset.%Next() {
       set json ={}
       set json.Profile= rset."profile_id"
       set json.MissedMeasure= rset."Type_Measure"
       set json.MissedPeriod= rset."Heure_Ratée"
       set json.Practionner= rset."Practitioner_Id"
       set json.ContactType= rset."Warning_Type"
       
       write json.%ToJSON()
       do array.%Push(json)
     }