We use Lotus Notes as our e-mail standard. The COM objects are included with the Lotus Notes installation. There is also a help library (Notes variety) with the Domino Server development package. The following VFP8SP1 code will create and send an e-mail with an attachment. For VFP7 take the TRY...CATCH and back it down to an ERROR event.
DIMENSION laSendTo[1]
oNotesSession = CREATEOBJECT("Lotus.NotesSession")
TRY
oNotesSession.Initialize(ALLTRIM(THIS.Value)) && Will give an OLE Exception Error if an error occurs
CATCH TO loException WHEN loException.ErrorNo = 1429
AERROR(laCOMException)
DO CASE
CASE laCOMException[7,1] = 4000
MESSAGEBOX("Notes error: Wrong Password. " +;
"(Passwords are case sensitive - be sure to use correct " +;
"upper and lower case.)",;
MB_ICONEXCLAMATION,;
THISFORM.Caption)
lblnError = TRUE
CASE laCOMException[7,1] = 4492
OTHERWISE
&& Do primary error handler
ENDCASE
CATCH TO loException
THISFORM.MousePointer = MOUSE_DEFAULT
&& Do Primary error handler
ENDTRY
lsMailServer = oNotesSession.GetEnvironmentString("MailServer", TRUE)
lsMailDB = oNotesSession.GetEnvironmentString("MailFile", TRUE)
loDB = oNotesSession.GetDatabase(lsMailServer, lsMailDB)
loDoc = loDB.CreateDocument()
loDoc.ReplaceItemValue("Subject", "Subject Text Here")
laSendTo[1] = "{Your Persons e-mail}"
loDoc.ReplaceItemValue("SendTo", @laSendTo)
loRTF = loDoc.CreateRichTextItem("Body")
WITH loRTF
.AppendText("Here is line 1")
.AddNewLine(1, TRUE)
.AppendText("Here is line 2")
.AddNewLine(1, TRUE)
&& This line adds an attachment there are other types this one is TEXT
.EmbedObject(1454, "", "C:\SomeData.txt")
.AddNewLine(2, TRUE)
.AppendText("***THIS IS AN AUTOMATED E-MAIL***")
.AddNewLine(1,TRUE)
.AppendText("You can reply to this message, if necessary.")
ENDWITH &&loRTF
loDoc.SaveMessageOnSend = TRUE && Saves a copy to sent folder
loDoc.Send(FALSE) && Sends the message
{End of code}
There was an article in the Virual Foxpro User Groups Newsletter back in I think September 2003. Check
www.vfug.org.
HTH
Richard
>Hi,
>
>Within our VFP7.0 application we send email automatically
>using the MAPI class to Outlook Express. However, one of
>our clients would like to be able to send email via Lotus
>Notes.
>
>Can anyone give me any help in doing this?
>
>Thanks in advance,
>
>Pauline
State of Florida, DCF