Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Lotus Notes - Read and Send EMail using VFP
Message
From
20/07/2003 15:38:53
Cindy Winegarden
Duke University Medical Center
Durham, North Carolina, United States
 
 
To
19/07/2003 19:21:46
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00811809
Message ID:
00811856
Views:
13
This message has been marked as the solution to the initial question of the thread.
>i like to try create app can read and send email from lotus notes V.6, does anyone have development..?

Here's code I'm using
*!* =========================================== *!*
*!* Automate Lotus Notes to send mail with attachments
*!* Open a command prompt window, 
*!*	change to the Notes program directory and run "regsvr32 nlsxbe.dll".
*!*	This registers the backend class library. 
*!* The Notes process is NLNotes.EXE

DEFINE CLASS cusNotesAutomation AS CUSTOM

	oNotes = ""
	oNotesDbDirectory = ""
	oNotesDatabase = ""
	cPassword = ""

	lSaveOnSend = .F.
	lEncryptOnSend = .F.

	DIMENSION aRecipients(1)
	cSubject = ""
	cBody = ""
	DIMENSION aAttachments(1)

	*!* =========================================== *!*
	FUNCTION OpenNotes()

		WITH THIS

			*!* Creates session or gets a handle to existing session.
			.oNotes = CREATEOBJECT("Lotus.NotesSession")
			.oNotes.Initialize(.cPassword)
			.oNotesDbDirectory = .oNotes.GetDbDirectory("")
			.oNotesDatabase = .oNotesDbDirectory.OpenMailDatabase()

		ENDWITH

	ENDFUNC

	*!* =========================================== *!*
	FUNCTION SendNotesMail()

		*!* Notes requires the array of recipients to be one-dimentional.
		LOCAL ARRAY laRecipients(1), laAttachments(1)
		LOCAL lcResults, lcSuccess
		LOCAL loNotesDocument, loNotesRichTextItem, loAttachment	

		ACOPY(THIS.aRecipients, laRecipients)
		ACOPY(THIS.aAttachments, laAttachments)

		lcSuccess = ""
		loNotesDocument = THIS.oNotesDatabase.CreateDocument()

		WITH loNotesDocument

			*!* TODO: Check for recipients, text, attachments.

			*!* Letterhead
			.ReplaceItemValue("Logo", "Plain Text")

			*!* Recipients
			.ReplaceItemValue("SendTo", @laRecipients)

			*!* Subject
			.ReplaceItemValue("Subject", THIS.cSubject)

			*!* Body and Attachments
			DO CASE
			
				*!* If we only have an attachment we'll embed it - it's prettier this way.
				CASE (LEN(ALLTRIM(THIS.cBody)) = 0) AND (TYPE("laAttachments(1)") = "C")
					loRichTextItem = .CreateRichTextItem("Body")
					
				*!* Here add the body and maybe create an attachment.
				CASE LEN(ALLTRIM(THIS.cBody)) > 0
					.ReplaceItemValue("Body", THIS.cBody)				

					IF TYPE("laAttachments(1)") = "C"
						loRichTextItem = .CreateRichTextItem("Attachment")
					ENDIF
					
				*!* If we get here we have neither body text nor an attachment.
				*!* While this is silly it won't create an error.
				OTHERWISE
					*!* TODO
			ENDCASE

			*!* Attachments - if we have any.
			IF TYPE("loRichTextItem" ) = "O"
				FOR EACH loAttachment IN laAttachments
					IF TYPE("loAttachment") = "C"
						loRichTextItem.EmbedObject(1454, "", loAttachment)
					ENDIF
				ENDFOR
			ENDIF

			*!* Message settings
			.SaveMessageOnSend = THIS.lSaveOnSend
			.EncryptOnSend = THIS.lEncryptOnSend

			*!* Send the message
			.SEND(0)
			lcSuccess = "Message sent successfully." 	&& + lcSuccess

		ENDWITH

		RETURN lcSuccess

	ENDFUNC

	*!* =========================================== *!*

ENDDEFINE
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform