I have been using this example from an earlier post to send mail using Lotus Notes 5.0, but seem to always say that my password is wrong
Is there any settings that I need to do first before using this. I already have the client (admin and user) installed. DO I need to do anything else ??
Is there an easier way ??
CHEERS GUYS !!! (and Girls)
Sum Pun
***********************
* SNDNOTES.PRG
* Function to send an email message from Lotus Notes using Notes R5 COM
* Author: David B. Cass
* (c) Copyright 2000 - May be freely distributed
* Parameters: pcServer: The Lotus Notes server on which the mail database resides
* pcNSF: The Notes NSF file containing the mail database
* pcPassword: Password used in the local user.id file
* pcSendTo: The list of TO addressees to which the email message should be sent
* pcSendCC: The list of CC addressees to which the email message should be sent
* pcSendBC: The list of BC addressees to which the email message should be sent
* pcSubject: The subject of the email message
* pcBody: The body of the email message
* pcAttachment: Comma separated list of file names to attach to the email message
* plQuiet: .T. to supress MESSAGEBOX() messages
*
* Returns: .T. if successful, .F. if unsuccessful
*
PARAMETER
pcServer,pcNSF,pcPassword,pcSendTo,pcSendCC,pcSendBC,pcSubject,pcBody,pcAttachments,plQuiet
PRIVATE
loNotesSession,loNotesDatabase,loMessage,loBody,ltMessageDateTime,llErr,lcErrorHandler,lcUserName
* Section 1 - Clean up the parameters
IF TYPE("plQuiet"#'L'
plQuiet = .F.
ENDIF
IF TYPE("pcServer"#'C'
pcServer = ""
ELSE
pcServer = ALLTRIM(pcServer)
ENDIF
IF TYPE("pcNSF"#'C' .OR. EMPTY(pcNSF)
IF !plQuiet
MESSAGEBOX("Must specify a database file",16)
ENDIF
RETURN .F.
ELSE
pcNSF = ALLTRIM(pcNSF)
ENDIF
IF TYPE("pcPassword"#'C'
pcPassword = ""
ENDIF
IF TYPE("pcSendTo"#'C'
pcSendTo = ""
ELSE
pcSendTo = ALLTRIM(pcSendTo)
ENDIF
IF TYPE("pcSendCC"#'C'
pcSendCC = ""
ELSE
pcSendCC = ALLTRIM(pcSendCC)
ENDIF
IF TYPE("pcSendBC"#'C'
pcSendBC = ""
ELSE
pcSendBC = ALLTRIM(pcSendBC)
ENDIF
IF EMPTY(pcSendTo+pcSendCC+pcSendBC)
IF !plQuiet
MESSAGEBOX("Must specify at least one addressee",16)
ENDIF
RETURN .F.
ENDIF
IF TYPE("pcSubject"#'C'
pcSubject = ""
ELSE
pcSubject = ALLTRIM(pcSubject)
ENDIF
IF TYPE("pcBody"#'C'
pcBody = ""
ENDIF
IF TYPE("pcAttachments"#'C'
pcAttachments = ""
ENDIF
IF EMPTY(pcBody+pcAttachments)
IF !plQuiet
MESSAGEBOX("Must specify email contents",16)
ENDIF
RETURN .F.
ENDIF
* Section 2 - Connect to Lotus Notes COM and log in
lcErrorHandler = ON("ERROR"
ON ERROR STORE .T. TO llErr
loNotesSession = CREATEOBJECT("Lotus.NotesSession"
ON ERROR &lcErrorHandler
IF TYPE("loNotesSession"#'O' .OR. ISNULL(loNotesSession)
IF !plQuiet
MESSAGEBOX("Lotus Notes/Domino COM cannot be loaded. Check to see that you have Lotus Notes R5 or Lotus Domino R5 loaded on your workstation.",16)
ENDIF
RETURN .F.
ENDIF
ON ERROR STORE .T. TO llErr
loNotesSession.initialize(pcPassword)
ON ERROR &lcErrorHandler
IF TYPE("loNotesSession.username"#'C' .OR. EMPTY(loNotesSession.username)
IF !plQuiet
MESSAGEBOX("The password you specified was not valid.",16)
ENDIF
loNotesSession = .NULL.
RETURN .F.
ENDIF
lcUserName = loNotesSession.username
* Section 3 - Open the Lotus Notes database specified in parameter pcNSF
loNotesDatabase = loNotesSession.getdatabase(pcServer,pcNSF)
IF TYPE("loNotesDatabase"#'O' .OR. ISNULL(loNotesDatabase) .OR. !loNotesDatabase.isopen
IF !plQuiet
MESSAGEBOX("Could not open the " +IIF(EMPTY(pcServer),"local Notes database "+pcNSF,pcNSF+"database on server "+pcServer),16)
ENDIF
loNotesDatabase = .NULL.
loNotesSession = .NULL.
RETURN .F.
ENDIF
* Section 4 - Create the header of the message
ltMessageDateTime = DATETIME()
loMessage = loNotesDatabase.createdocument
loMessage.appenditemvalue("authorlist",lcUserName)
loMessage.appenditemvalue("BlindCopyTo",pcSendBC)
loMessage.appenditemvalue("copyto",pcSendCC)
loMessage.appenditemvalue("defaultmailsaveoption","1"
loMessage.appenditemvalue("encrypt","0"
loMessage.appenditemvalue("form","Memo"
loMessage.appenditemvalue("from",lcUserName)
loMessage.appenditemvalue("logo",""
loMessage.appenditemvalue("mailoptions","0"
loMessage.appenditemvalue("mailsaveoptions","1"
loMessage.appenditemvalue("posteddate",ltMessageDateTime)
loMessage.appenditemvalue("principal",lcUserName)
loMessage.appenditemvalue("recipients",pcSendTo)
loMessage.appenditemvalue("SaveOptions","1"
loMessage.appenditemvalue("Securemail",""
loMessage.appenditemvalue("sendertag",""
loMessage.appenditemvalue("sendto",pcSendTo)
loMessage.appenditemvalue("sign","0"
loMessage.appenditemvalue("subject",pcSubject)
loMessage.appenditemvalue("tmpdate",ltMessageDateTime)
loMessage.appenditemvalue("$Keepprivate",""
loMessage.appenditemvalue("$Revision",ltMessageDateTime)
loMessage.appenditemvalue("$Updateby",lcUserName)
* Section 5 - Create the body of the message
loBody = loMessage.createrichtextitem("body"
IF !EMPTY(pcBody)
loBody.appendtext(pcBody)
ENDIF
* Section 6 - Add any attachments to the body of the message
IF !EMPTY(pcAttachments)
loBody.addnewline(2)
STORE pcAttachments TO lcAttachments
DO WHILE !EMPTY(lcAttachments)
IF "," $ lcAttachments
lcThisAttachment = ALLTRIM(LEFT(lcAttachments,AT(",",lcAttachments)-1))
lcAttachments = ALLTRIM(SUBSTR(lcAttachments,AT(",",lcAttachments)+1))
ELSE
lcThisAttachment = lcAttachments
lcAttachments = ""
ENDIF
DO CASE
CASE EMPTY(lcThisAttachment)
CASE !FILE(lcThisAttachment)
IF !plQuiet
MESSAGEBOX("Attachment "+lcThisAttachment+" does not exist.",16)
ENDIF
loBody = .NULL.
loMessage = .NULL.
loNotesDatabase = .NULL.
loNotesSession = .NULL.
RETURN .F.
OTHERWISE
loBody.addnewline(1)
loBody.embedobject(1454,"",lcThisAttachment,""
ENDCASE
ENDDO
ENDIF
* Section 7 - Save and send the message
loMessage.SAVE(.T.,.T.)
loMessage.SEND(.F.)
* Clear the link to the Lotus Notes COM
loBody = .NULL.
loMessage = .NULL.
loNotesDatabase = .NULL.
loNotesSession = .NULL.
IF !plQuiet
MESSAGEBOX("You email message has been sent"
ENDIF
RETURN .T.
Coding by :
David B. Cass
U.S. Navy, FISC Norfolk, VA
***********************************
Is there any settings that I need to do first before using this. I already have the client (admin and user) installed. DO I need to do anything else ??
Is there an easier way ??
CHEERS GUYS !!! (and Girls)
Sum Pun
***********************
* SNDNOTES.PRG
* Function to send an email message from Lotus Notes using Notes R5 COM
* Author: David B. Cass
* (c) Copyright 2000 - May be freely distributed
* Parameters: pcServer: The Lotus Notes server on which the mail database resides
* pcNSF: The Notes NSF file containing the mail database
* pcPassword: Password used in the local user.id file
* pcSendTo: The list of TO addressees to which the email message should be sent
* pcSendCC: The list of CC addressees to which the email message should be sent
* pcSendBC: The list of BC addressees to which the email message should be sent
* pcSubject: The subject of the email message
* pcBody: The body of the email message
* pcAttachment: Comma separated list of file names to attach to the email message
* plQuiet: .T. to supress MESSAGEBOX() messages
*
* Returns: .T. if successful, .F. if unsuccessful
*
PARAMETER
pcServer,pcNSF,pcPassword,pcSendTo,pcSendCC,pcSendBC,pcSubject,pcBody,pcAttachments,plQuiet
PRIVATE
loNotesSession,loNotesDatabase,loMessage,loBody,ltMessageDateTime,llErr,lcErrorHandler,lcUserName
* Section 1 - Clean up the parameters
IF TYPE("plQuiet"#'L'
plQuiet = .F.
ENDIF
IF TYPE("pcServer"#'C'
pcServer = ""
ELSE
pcServer = ALLTRIM(pcServer)
ENDIF
IF TYPE("pcNSF"#'C' .OR. EMPTY(pcNSF)
IF !plQuiet
MESSAGEBOX("Must specify a database file",16)
ENDIF
RETURN .F.
ELSE
pcNSF = ALLTRIM(pcNSF)
ENDIF
IF TYPE("pcPassword"#'C'
pcPassword = ""
ENDIF
IF TYPE("pcSendTo"#'C'
pcSendTo = ""
ELSE
pcSendTo = ALLTRIM(pcSendTo)
ENDIF
IF TYPE("pcSendCC"#'C'
pcSendCC = ""
ELSE
pcSendCC = ALLTRIM(pcSendCC)
ENDIF
IF TYPE("pcSendBC"#'C'
pcSendBC = ""
ELSE
pcSendBC = ALLTRIM(pcSendBC)
ENDIF
IF EMPTY(pcSendTo+pcSendCC+pcSendBC)
IF !plQuiet
MESSAGEBOX("Must specify at least one addressee",16)
ENDIF
RETURN .F.
ENDIF
IF TYPE("pcSubject"#'C'
pcSubject = ""
ELSE
pcSubject = ALLTRIM(pcSubject)
ENDIF
IF TYPE("pcBody"#'C'
pcBody = ""
ENDIF
IF TYPE("pcAttachments"#'C'
pcAttachments = ""
ENDIF
IF EMPTY(pcBody+pcAttachments)
IF !plQuiet
MESSAGEBOX("Must specify email contents",16)
ENDIF
RETURN .F.
ENDIF
* Section 2 - Connect to Lotus Notes COM and log in
lcErrorHandler = ON("ERROR"
ON ERROR STORE .T. TO llErr
loNotesSession = CREATEOBJECT("Lotus.NotesSession"
ON ERROR &lcErrorHandler
IF TYPE("loNotesSession"#'O' .OR. ISNULL(loNotesSession)
IF !plQuiet
MESSAGEBOX("Lotus Notes/Domino COM cannot be loaded. Check to see that you have Lotus Notes R5 or Lotus Domino R5 loaded on your workstation.",16)
ENDIF
RETURN .F.
ENDIF
ON ERROR STORE .T. TO llErr
loNotesSession.initialize(pcPassword)
ON ERROR &lcErrorHandler
IF TYPE("loNotesSession.username"#'C' .OR. EMPTY(loNotesSession.username)
IF !plQuiet
MESSAGEBOX("The password you specified was not valid.",16)
ENDIF
loNotesSession = .NULL.
RETURN .F.
ENDIF
lcUserName = loNotesSession.username
* Section 3 - Open the Lotus Notes database specified in parameter pcNSF
loNotesDatabase = loNotesSession.getdatabase(pcServer,pcNSF)
IF TYPE("loNotesDatabase"#'O' .OR. ISNULL(loNotesDatabase) .OR. !loNotesDatabase.isopen
IF !plQuiet
MESSAGEBOX("Could not open the " +IIF(EMPTY(pcServer),"local Notes database "+pcNSF,pcNSF+"database on server "+pcServer),16)
ENDIF
loNotesDatabase = .NULL.
loNotesSession = .NULL.
RETURN .F.
ENDIF
* Section 4 - Create the header of the message
ltMessageDateTime = DATETIME()
loMessage = loNotesDatabase.createdocument
loMessage.appenditemvalue("authorlist",lcUserName)
loMessage.appenditemvalue("BlindCopyTo",pcSendBC)
loMessage.appenditemvalue("copyto",pcSendCC)
loMessage.appenditemvalue("defaultmailsaveoption","1"
loMessage.appenditemvalue("encrypt","0"
loMessage.appenditemvalue("form","Memo"
loMessage.appenditemvalue("from",lcUserName)
loMessage.appenditemvalue("logo",""
loMessage.appenditemvalue("mailoptions","0"
loMessage.appenditemvalue("mailsaveoptions","1"
loMessage.appenditemvalue("posteddate",ltMessageDateTime)
loMessage.appenditemvalue("principal",lcUserName)
loMessage.appenditemvalue("recipients",pcSendTo)
loMessage.appenditemvalue("SaveOptions","1"
loMessage.appenditemvalue("Securemail",""
loMessage.appenditemvalue("sendertag",""
loMessage.appenditemvalue("sendto",pcSendTo)
loMessage.appenditemvalue("sign","0"
loMessage.appenditemvalue("subject",pcSubject)
loMessage.appenditemvalue("tmpdate",ltMessageDateTime)
loMessage.appenditemvalue("$Keepprivate",""
loMessage.appenditemvalue("$Revision",ltMessageDateTime)
loMessage.appenditemvalue("$Updateby",lcUserName)
* Section 5 - Create the body of the message
loBody = loMessage.createrichtextitem("body"
IF !EMPTY(pcBody)
loBody.appendtext(pcBody)
ENDIF
* Section 6 - Add any attachments to the body of the message
IF !EMPTY(pcAttachments)
loBody.addnewline(2)
STORE pcAttachments TO lcAttachments
DO WHILE !EMPTY(lcAttachments)
IF "," $ lcAttachments
lcThisAttachment = ALLTRIM(LEFT(lcAttachments,AT(",",lcAttachments)-1))
lcAttachments = ALLTRIM(SUBSTR(lcAttachments,AT(",",lcAttachments)+1))
ELSE
lcThisAttachment = lcAttachments
lcAttachments = ""
ENDIF
DO CASE
CASE EMPTY(lcThisAttachment)
CASE !FILE(lcThisAttachment)
IF !plQuiet
MESSAGEBOX("Attachment "+lcThisAttachment+" does not exist.",16)
ENDIF
loBody = .NULL.
loMessage = .NULL.
loNotesDatabase = .NULL.
loNotesSession = .NULL.
RETURN .F.
OTHERWISE
loBody.addnewline(1)
loBody.embedobject(1454,"",lcThisAttachment,""
ENDCASE
ENDDO
ENDIF
* Section 7 - Save and send the message
loMessage.SAVE(.T.,.T.)
loMessage.SEND(.F.)
* Clear the link to the Lotus Notes COM
loBody = .NULL.
loMessage = .NULL.
loNotesDatabase = .NULL.
loNotesSession = .NULL.
IF !plQuiet
MESSAGEBOX("You email message has been sent"
ENDIF
RETURN .T.
Coding by :
David B. Cass
U.S. Navy, FISC Norfolk, VA
***********************************