Good day everybody,

I have read in a response by Cindy Winegarden that we can use VFP to send
email via Lotus Notes. This is what I need to do in my project. Unfortunately
Rusty is using Outlook, so Cindy didn't provide the method on how to do in
Lotus Notes.

Can Cindy or anyone provide me the way on how to do it? I have some
information already build in my application database, and need to pass some
of them(as text) via email to selected person.

Another question is, at the created Lotus Notes email, is it possible to
embedded a link to launch the VFP application? As the person receive the
email, will have to run my application to do something. The application will
be located in a server and all the users have access to the server.

Hope to hear from you and Have a nice day.

Best regards,
Julie

Re: Use VFP 8.0 to send email via Lotus Notes by Olaf

Olaf
Tue Jun 26 04:07:49 CDT 2007

Hi Julie,

the fox wiki has collected a variety of possibilities
to send automated mail:

http://fox.wikis.com/wc.dll?Wiki~AutomatedEmail~VFP

besides others there's a link to

http://fox.wikis.com/wc.dll?Wiki~LotusNotesEmail

I don't know how lotus notes handles URLs within
mail bodies, Outlook does make them usable hyperlinks,
even if the mail is text only.

So I'd try simply putting something like

file://\\servername\share\application\yourapp.exe

and a click on that would start the exe.

If you do a html mail it should be possible to use
the a href="..." tag and even display some text like
"start myapp" instead of the URL.

Bye, Olaf.



Re: Use VFP 8.0 to send email via Lotus Notes by Cindy

Cindy
Tue Jun 26 12:04:09 CDT 2007

"Julie" <Julie@discussions.microsoft.com> wrote in message
news:D040811C-486B-455C-AC2D-84357C371EBC@microsoft.com...
> Good day everybody,
>
> I have read in a response by Cindy Winegarden that we can use VFP to send
> email via Lotus Notes. ....

Hi Julie,

Here's some code I use

>>>>
*-- ---------------------------------------------------------------
*-- 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()

Try
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

Catch To oException
*-- If we can't even initialize Notes we'll throw the error to the
calling routine.
Throw && oException

Endtry

Endfunc

*-- ---------------------------------------------------------------
Function SendNotesMail()

Try

*-- 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

*-- Check for recipients.
*-- THROW error if not found.
If Not (Type("laRecipients(1)") == "C" And Len(Alltrim(laRecipients(1)))
> 0)
Throw "No email recipients were specified."
*-- lcSuccess = "No recipients. "
Endif

*-- Check for subject, text, or attachments.
*-- THROW error if none are found.
If Not ((Len(Alltrim(This.cSubject)) > 0) Or ;
(Len(Alltrim(This.cBody)) > 0) Or ;
((Type("laAttachments(1)") = "C") And Len(Alltrim("laAttachments(1)"))
> 0))
Throw "No subject, body, or attachments specified."
*-- lcSuccess "Neither text nor attachment found for message to " +
tcRecipients + ". "
Endif

*-- ---------------------------------------------------------------
*-- If we get here we should be able to send successfully.

*-- 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

Otherwise
*-- If we get here we have neither body text nor an attachment.
*-- While this is silly it won't create an error.
lcSuccess = lcSuccess + "Neither a body nor an attachment were
provided. "
Endcase

*-- Attachments - if we have any.
If Type("loRichTextItem" ) = "O"
For Each loAttachment In laAttachments
If Type("loAttachment") = "C"
loRichTextItem.EmbedObject(1454, "", Alltrim(loAttachment))
Endif
Endfor
Endif

*-- Message settings.
.SaveMessageOnSend = This.lSaveOnSend
.EncryptOnSend = This.lEncryptOnSend

*-- Send the message. There is no return value from the Send() method.
.Send(0)
lcSuccess = lcSuccess + "Message sent successfully. "

Endwith

Catch

lcSuccess = "Unable to send message. "

Finally

* RETURN lcSuccess

Endtry

Endfunc

*-- ---------------------------------------------------------------

Enddefine
<<<<


Here's code where I send the mail

>>>>
*-- Create the Object properties
.oNotesMailer = CREATEOBJECT("cusNotesAutomation")
.oNotesMailer.cPassword = .cNotesPassword
.oNotesMailer.lSaveOnSend = .lSaveOnSend
.oNotesMailer.lEncryptOnSend = .lEncryptOnSend
.oNotesMailer.OpenNotes()

*-- Later in the program ....


*-- Clear the array of attachments from the last use and
*-- set up email properties for this recipient.
*-- Notes requires that the array of recipients be one-dimentional.
DIMENSION .oNotesMailer.aRecipients(1), .oNotesMailer.aAttachments(1)
.oNotesMailer.aRecipients(1) = ALLTRIM(WhoGetsTheReport.DempoID)
.oNotesMailer.cSubject = .cNotesMailSubject
.oNotesMailer.cBody = .cNotesMailBody
.oNotesMailer.aAttachments = .F.

*-- Add all the PDFs that belong to this recipient.
SELECT PDFList.PDFName ;
FROM PDFList ;
INTO ARRAY laDocList ;
WHERE PDFList.DempoID = WhoGetsTheReport.DempoID ;
GROUP BY 1

lnNumDocs = ACOPY(laDocList, .oNotesMailer.aAttachments)

*-- Send the message
lcSuccess = .oNotesMailer.SendNotesMail()


<<<<



--
Cindy Winegarden
cindy@cindywinegarden.com

VFP OLE DB: http://msdn2.microsoft.com/en-us/vfoxpro/bb190232.aspx
VFP ODBC: http://msdn2.microsoft.com/en-us/vfoxpro/bb190233.aspx


RE: Use VFP 8.0 to send email via Lotus Notes by Julie

Julie
Tue Jun 26 19:20:01 CDT 2007

Thank you Olaf, for the links and suggestion.

Thank you Cindy, for your code to use as reference/guidance.


RE: Use VFP 8.0 to send email via Lotus Notes by Julie

Julie
Wed Jun 27 00:20:01 CDT 2007

Hi Olaf and Cindy,

This is to let you know that I got the result that I want.
Thanks very much for your tips.

Have a wonderful day.

Best regards,
Julie

Re: Use VFP 8.0 to send email via Lotus Notes by Olaf

Olaf
Wed Jun 27 02:25:37 CDT 2007

> This is to let you know that I got the result that I want.
> Thanks very much for your tips.
Thanks for confirming the validity.

Bye, Olaf.