The solution for sending email through Office 365 (as it worked for me).
You would need to adjust according to taste. Hopefully enough detail is
provided to make it helpful.
— Chris Belanger
INTERPROCESS VARS:
<>eHOST — in this instance, is smtp.office365.com
<>eFROM — default email address of sender (can be over-ridden by caller)
<>CR [char(13)],
<>CurrentUserName [name of the user; for reminding them they must give the
needed fields as per the ALERT( ) ]
<>Auth_UN [email address]
<>Auth_PW [email account password]
//eMAIL_SEND_OFFICE_365(Host;From;To;CC;BCC;Subject;Body;Attachments)
C_TEXT($1;$2;$3;$4;$5;$6;$7;$8) // the items that make up the email
// we set up the following vars to clarify what is happening
C_TEXT($Host;$From;$To;$CC;$BCC;$Subject;$Body;$Attachments)
$Host:=$1
If ($Host="")
$Host:=<>eHOST
End if
$From:=$2
If ($From="")
$From:=<>eFROM
End if
If (($Host="") | ($From="")) // watch for situations where an eMail is going
to be sent for which we are lacking a HOST or FROM
ALERT("You must enter the eMail HOST & FROM fields in the USERS record
for "+<>CurrentUserName+" before you can send eMails.")
Else
$To:=$3
$CC:=$4
$BCC:=$5
$Subject:=$6
$Body:=$7+<>CR
$Attachments:=$8
C_BOOLEAN(<>ShowErrors)
<>ShowErrors:=True
C_LONGINT(SMTP_ID)
C_BOOLEAN($SentOK;$OK)
$SentOK:=False
$err:=IT_SetPort (2;587)
$wdw:=Open window(50;300;300;400;Modal dialog box)
STATUS_LINE (2;"Sending email...please wait")
Case of
: (Not(eMail_ERRCHECK ("SMTP_New";SMTP_New (SMTP_ID))))
: (Not(eMail_ERRCHECK ("SMTP_Host";SMTP_Host
(SMTP_ID;$Host;0))))
: (Not(eMail_ERRCHECK ("SMTP_From";SMTP_From
(SMTP_ID;$From;1))))
: (Not(eMail_ERRCHECK ("SMTP_ReplyTo";SMTP_ReplyTo
(SMTP_ID;$From;0))))
: (Not(eMail_ERRCHECK ("SMTP_To";SMTP_To (SMTP_ID;$To;0))))
: (Not(eMail_ERRCHECK ("SMTP_Cc";SMTP_Cc (SMTP_ID;$CC;0))))
: (Not(eMail_ERRCHECK ("SMTP_Bcc";SMTP_Bcc (SMTP_ID;$BCC;0))))
: (Not(eMail_ERRCHECK ("SMTP_Subject";SMTP_Subject
(SMTP_ID;$Subject;0))))
: (Not(eMail_ERRCHECK ("SMTP_Body";SMTP_Body
(SMTP_ID;$Body;0))))
: (Not(eMail_ERRCHECK ("SMTP_Attachment";SMTP_Attachment_It
(SMTP_ID;$Attachments;2;0))))
: (Not(eMail_ERRCHECK ("SMTP_Auth";SMTP_Auth
(SMTP_ID;<>Auth_UN;<>Auth_PW))))
: (Not(eMail_ERRCHECK ("SMTP_Send";SMTP_Send (SMTP_ID;0))))
: (Not(eMail_ERRCHECK ("SMTP_Clear";SMTP_Clear (SMTP_ID))))
End case
CLOSE WINDOW($wdw)
End if
——
// STATUS_LINE(Line#;Msg) -- put this message on prescribed line.
C_LONGINT($1)
C_TEXT($2)
GOTO XY(2;$1)
MESSAGE($2+(" "*40))
——
// eMail_ERRCHECK() -- used inside of our email-sender routine.
C_TEXT(vErrorMsg)
$Command:=$1
$Error:=$2
$Result:=True
If ($Error#0)
$Result:=False
If (<>SHOWERRORS) //Boolean to determine whether to display error
messages
vErrorMsg:=IT_ErrorText ($Error)
ALERT("ERROR ---"+Char(13)+"Command: "+$Command+Char(13)+"Error
Code"+String($Error)+Char(13)+"Description"+vErrorMsg)
End if
End if
$0:=$Result
**********************************************************************
4D Internet Users Group (4D iNUG)
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:[email protected]
**********************************************************************