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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mail from VFP to Notes 2

Status
Not open for further replies.

hagaleano

Programmer
Jul 24, 2003
8
0
0
BR
Hi!

I'm triying to send a notes mail from vfp, i found some help code in this forum, but this code is for Notes R5. I'm working in Notes 4.6 and get an error when use CreateRichTextItem, i need to attach a file in a message, but i don't know how can i do it in this version.

Can anyone help me?

Thanks a lot.
 

hagaleano

This suggestion from a VB site.

Remove the line:

MailDoc.CREATERICHTEXTITEM ....

This apparently happens with certain versions of Notes 4.x and the suggested cure is to remove this line but retain the previous two.


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Thanks Mike

I already do that but I don't know how to assign the attachment file name, where must i use EmbedObject property.

bye
 
Here is another quote I found (I'm not sure it acurate or not)

LotusNotes Automation Client
----------------------------

v1.00

Basic System which allows you to log into a Lotus Notes Mail Server. Retrieves system properties
and allows the user to send to a mail recipient.

Allows for attachments, and styles (currently set to dark green)

COM Automation will only work for Lotus Notes(R)/Domino(TM) 5.0.2b or higher (5.0.2c recommended)


For further information: visit:
Suggestions/Comments: email me at: Smithmark@btinternet.com




Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
I think I got this from here somewhere. However, it does say it is for release 5. We used 5.? and are now on 6 and this still works Ok.

* 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
* pcAttachments: 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
*
* Command Line: do sndnotes with pcServer,pcNSF,pcPassword,pcSendTo,pcSendCC,pcSendBC,pcSubject,pcBody,pcAttachments,plQuiet
*
*

PARAMETERS ;
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("Your email message has been sent")
ENDIF
RETURN .T.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top