We are using Lotus Notes instead of Outlook. How can we send e-mail with Notes?
Found on Peg, sent by Torben Jensby Christensen on 13 december 2002.
/* Procedure to send mail using Lotus Notes 4.6
*
* Has been tested to work with
* Lotus Notes 4.6.7
*
* 16.06.2000 TJC Created
* 30.07.2000 TJC modified to find users mail file
*/
DEFINE INPUT PARAMETER msgRecip AS CHAR NO-UNDO.
DEFINE INPUT PARAMETER msgTitle AS CHAR NO-UNDO.
DEFINE INPUT PARAMETER msgBody AS CHAR NO-UNDO.
DEFINE INPUT PARAMETER msgAttach AS CHAR NO-UNDO.
IF msgRecip = "":U THEN DO:
MESSAGE "No recipient entered, no mail created":T80
VIEW-AS ALERT-BOX INFO BUTTONS OK.
RETURN ERROR.
END.
DEFINE VARIABLE EMBED_ATTACHMENT AS INT INIT 1454.
DEFINE VARIABLE notesSession AS COM-HANDLE.
DEFINE VARIABLE notesDB AS COM-HANDLE.
DEFINE VARIABLE notesDoc AS COM-HANDLE.
DEFINE VARIABLE notesAttach AS COM-HANDLE.
DEFINE VARIABLE curattach AS CHAR NO-UNDO.
DEFINE VARIABLE i AS INT NO-UNDO.
DEFINE VARIABLE j AS INT NO-UNDO.
DEFINE VARIABLE mail-file AS CHAR NO-UNDO.
DEFINE VARIABLE mail-server AS CHAR NO-UNDO.
/* Create a session and log on -- username and password in profile */
CREATE "NOTES.NOTESSESSION":U notesSession NO-ERROR.
IF ERROR-STATUS:ERROR THEN DO:
MESSAGE "Unable to connect to users mail file":T80
VIEW-AS ALERT-BOX ERROR BUTTONS OK.
RETURN.
END.
mail-file = notessession:GetEnvironmentString("MailFile":U,YES).
IF mail-file = "" THEN DO:
MESSAGE "Unable to connect to users mail file":T80
VIEW-AS ALERT-BOX ERROR BUTTONS OK.
RETURN.
END.
mail-server = notessession:GetEnvironmentString("MailServer":U,YES).
/* Set db and create document */
notesDB = notessession:GetDatabase(mail-server , mail-file).
/* create a message and fill in its properties */
ASSIGN
notesDoc = notesDB:CREATEDOCUMENT
notesdoc:Form = "Memo":U
notesDoc:Subject = msgtitle
notesDoc:Body = msgbody
msgrecip = REPLACE(msgrecip,"|":U,",":U)
notesDoc:SendTo = msgrecip
NO-ERROR.
/* Create attachments */
DO i = 1 TO NUM-ENTRIES(msgAttach,"|":U):
curAttach = ENTRY(i,msgAttach,"|":U).
IF curattach NE "":U THEN DO:
notesAttach = notesDoc:CreateRichTextItem("API PRO file":U).
notesAttach:EMBEDOBJECT(EMBED_ATTACHMENT, 0, curattach,"API PRO file":U).
END.
END.
/* notesDoc:save(true, false). */
ASSIGN
notesDoc:SaveMessageOnSend = TRUE
NO-ERROR.
notesDoc:send(False, msgrecip).
IF msgattach GT "":U THEN RELEASE OBJECT notesAttach NO-ERROR.
RELEASE OBJECT notesDoc NO-ERROR.
RELEASE OBJECT notesDB NO-ERROR.
RELEASE OBJECT notesSession NO-ERROR
There is a similar, but different solution available at freeframework: http://www.freeframework.org/downloads/4gl-util/