When looking at how to use TCP in 4D, I came across this variation of the Duff Device in the documentation:
$SentOK:=False //A flag to indicate if we made it through all of the calls
Case of
: (SMTP_New ($smtp_id)!=0)
: (SMTP_Host ($smtp_id;<>pref_Server)!=0)
: (SMTP_From ($smtp_id;vFrom)!=0)
: (SMTP_To ($smtp_id;vTo)!=0)
: (SMTP_Subject ($smtp_id;vSubject)!=0)
: (SMTP_Body ($smtp_id;vMessage)!=0)
: (SMTP_Send ($smtp_id)!=0)
Else
$SentOK:=True //message was composed and mailed successfully
End case
If ($smtp_id!=0) //If a Message Envelope was created we should clear it now
$OK:=SMTP_Clear ($smtp_id)
End if
I looked at it and thought it was really clever (I still do). Unfortunately, it wasn't what I needed and I never got the chance to use it.