StartItem:
PUBLIC
PROC [msH: MailSendHandle, type: MailBasics.ItemType] ~ {
bodyPartInfo: BodyPartInfo ¬ NEW[MailSend.BodyPartInfoObject ¬ [type, NIL]];
IF msH.bodyParts =
NIL
THEN msH.lastBodyPart ¬ msH.bodyParts ¬ LIST[bodyPartInfo]
ELSE msH.lastBodyPart ¬ msH.lastBodyPart.rest ¬ LIST[bodyPartInfo];
msH.nBodyParts ¬ msH.nBodyParts.SUCC;
};
AddToItem:
PUBLIC
PROC [msH: MailSendHandle, buffer:
ROPE] ~ {
msH.lastBodyPart.first.data ¬ Rope.Concat[msH.lastBodyPart.first.data, buffer];
};
Send:
PUBLIC
PROC [msH: MailSendHandle, validate, sendEvenIfInvalidNames:
BOOL, transport:
ATOM ¬ $any]
RETURNS [sent:
BOOL, failureReason:
ROPE, invalidNames: MailBasics.RNameList] ~ {
procs: MailSendProcsRef;
IF msH.recipients = NIL THEN RETURN[FALSE, "No recipients.", NIL];
IF msH.bodyParts = NIL THEN RETURN[FALSE, "No Items.", NIL];
IF transport = $any
THEN {
IF ( procs ¬ GetRegisteredMailSendProcs[$xns] ) = NIL THEN
procs ¬ GetRegisteredMailSendProcs[$gv];
IF procs = NIL THEN RETURN[FALSE, "No transport available", NIL];
}
ELSE IF (procs ¬ GetRegisteredMailSendProcs[transport]) = NIL THEN
RETURN[FALSE, IO.PutFR1["Transport: %g not available.", [atom[transport]] ], NIL ];
[sent, failureReason, invalidNames] ¬ procs.Send[msH, validate, sendEvenIfInvalidNames];
};
SendWithAbort:
PUBLIC
PROC [msH: MailSendHandle, validate, sendEvenIfInvalidNames, allowDLRecipients:
BOOL, abortSend: AbortSendProc, transport:
ATOM ¬ $any]
RETURNS [sent: BOOL, failureReason: ROPE, invalidNames, dlsNotAllowed, fakeDls: MailBasics.RNameList] ~ {
procs: MailSendSidedoorProcsRef;
IF msH.recipients = NIL THEN RETURN[FALSE, "No recipients.", NIL, NIL, NIL];
IF msH.bodyParts = NIL THEN RETURN[FALSE, "No Items.", NIL, NIL, NIL];
IF transport = $any
THEN {
IF ( procs ¬ GetRegisteredMailSendSidedoorProcs[$xns] ) = NIL THEN
procs ¬ GetRegisteredMailSendSidedoorProcs[$gv];
IF procs = NIL THEN RETURN[FALSE, "No transport available", NIL, NIL, NIL];
}
ELSE IF (procs ¬ GetRegisteredMailSendSidedoorProcs[transport]) = NIL THEN
RETURN[FALSE, IO.PutFR1["Transport: %g not available.", [atom[transport]] ], NIL, NIL, NIL ];
[sent, failureReason, invalidNames, dlsNotAllowed, fakeDls] ¬
procs.SendWithAbort[msH, validate, sendEvenIfInvalidNames, allowDLRecipients, abortSend];
};