Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VFP8 to Lotus Notes v5

Status
Not open for further replies.

ROGERDODGE

IS-IT--Management
Aug 13, 2003
40
GB
Can anyone shed any light. We had an application which sent emails directly using Notes r4. Since customer upgraded to Notes r5 it doesnt work. I understand there are a lot of changes to the Notes Object.

To add to my problems, my customer is 400 miles away and I dont have Notes on my system.

I am therefore sending them a basic form with button to send mail to me. I have logged the steps and conclude that it falls over on the GetDatabase.

Question 1 - Can I connect to the database without supplying any credentials ??

If no, I have tried to pull the information using:

m.MailFile = loSession.GetEnvironmentString("MailFile", .T.)
m.MailServer = loSession.GetEnvironmentString("MailServer", .T.)

Either way, I get an OLE exception code 7060 when trying to get the database.

Alternatively is there any way I can simulate the Notes server ??

Any help would be very useful

Roger Maynard

 
ROGERDODGE

The only thing I found a while ago is the following, that might help you solve your problem (note I'm not the author of this):
Code:
* 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.

David B. Cass
U.S. Navy, FISC Norfolk, VA



Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top