WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Lotus Notes

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Catastrophic Failure in Lotus Notes


Question:

Has anyone tried sending email through Lotus notes using the example from the Tech database on the latest version of Winbatch? Winbatch ver 2004F, WIL Version 5.4fed. I am using Notes 6.5 and do not have a problem with 2004A.
Session = ObjectCreate("Notes.NotesSession")
db = Session.GetDatabase("", "")

If db.IsOpen == @False then db.OpenMail
doc = db.CreateDocument
doc.Form = "Memo" ;<--- stops here
Error I receive:
1298: Ole: Error code not recognised
On line: doc.Form = "Memo"
WWWBatch.ini listing:
[COM Sub-system]
Function=InvokeMember
ErrorCode=65535 (0x8000FFFF)
ErrorDesc=Catastrophic failure
I tried rebooting and ran the code again. Here is my debug trace:
*********************************************
*** Debug Initialized ***

==============================
Wed 10/13/2004 3:31:26 PM
WinBatch 32 2004F
WIL DLL 5.4fed
E:\ic\PCOMM\Interaction Center Start.wbt
Windows platform: NT, version: 5.0, build: 2195 (Service Pack 4)
==============================

--- (15) In UDF (sendlotusnotesmail) ---
Wed 10/13/2004 3:31:26 PM

Session = ObjectCreate("Notes.NotesSession")
(15) VALUE=> 1638996

db = Session.GetDatabase("", "")
(31) VALUE=> 1648452

If db.IsOpen == @False then db.OpenMail
(265) ==>TRUE=> 

doc = db.CreateDocument
(281) VALUE=> 1649332

doc.Form = 'Memo'
(2750) VALUE=> Memo

TERMINAL WIL ERROR=>1298 (Ole: Error code not recognised)

--- Leaving UDF (sendlotusnotesmail) --- 

Answer:

Well it may be that "Memo" isn't among your forms, or somehow not defined, or has another method of accessing it.

Do you have a VB example ?

Does Lotus Notes have a "macro recorder" like MS Excel? If so, record a macro of the process you're attempting, then cut & paste a copy of it here.

Last resort, go to the Lotus homepage and see if they have VB examples there.

User Reply:

The sad thing is, this worked in all of my other version of winbatch - 2004B and lower. If you search on VB6 sent Lotus notes using http://groups.google.com, there are a few hundred examples. The "memo" field is actually a required field. It looks like I cannot access any of the properties from the line 'doc = db.CreateDocument'
i.e. doc.Form = 'Memo'
doc.subject = "Logs"
doc.Body = "Free form text"
I have attached a VB example, also the example I have above is right out of the tech database.
Public Sub SendNotesMail(Subject As String, attachment As String, recipient As String, bodytext As String, saveit As Boolean) 
'Set up the objects required for Automation into lotus notes 
    Dim Maildb As Object 'The mail database 
    Dim UserName As String 'The current users notes name 
    Dim MailDbName As String 'THe current users notes mail database name 
    Dim MailDoc As Object 'The mail document itself 
    Dim AttachME As Object 'The attachment richtextfile object 
    Dim Session As Object 'The notes session 
    Dim EmbedObj As Object 'The embedded object (Attachment) 
    'Start a session to notes 
    Set Session = CreateObject("Notes.NotesSession") 
    'Get the sessions username and then calculate the mail file name 
    'You may or may not need this as for MailDBname with some systems you 
    'can pass an empty string 
    UserName = Session.UserName 
    MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf" 
    'Open the mail database in notes 
    Set Maildb = Session.GETDATABASE("", MailDbName) 
     If Maildb.IsOpen = True Then 
          'Already open for mail 
     Else 
         Maildb.OPENMAIL 
     End If 
    'Set up the new mail document 
    Set MailDoc = Maildb.CREATEDOCUMENT 
    MailDoc.Form = "Memo" 
    MailDoc.sendto = recipient 
    MailDoc.Subject = Subject 
    MailDoc.Body = bodytext 
    MailDoc.SAVEMESSAGEONSEND = saveit 
    'Set up the embedded object and attachment and attach it 
    If attachment <> "" Then 
        Set AttachME = MailDoc.CREATERICHTEXTITEM("Attachment") 
        Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", attachment, "Attachment") 
        MailDoc.CREATERICHTEXTITEM ("Attachment") 
    End If 
    'Send the document 
    MailDoc.PostedDate = Now() 'Gets the mail to appear in the sent items folder 
    MailDoc.SEND 0, recipient 
    'Clean Up 
    Set Maildb = Nothing 
    Set MailDoc = Nothing 
    Set AttachME = Nothing 
    Set Session = Nothing 
    Set EmbedObj = Nothing 
End Sub

Answer:

Well, I would follow the case of the VB sample exactly and use
db.CREATEDOCUMENT
I realize that the trace didn't show an error there, but case is sometimes an issue in OLE.

Here is some code I found that might be worth a look:

Session = ObjectCreate("Notes.NotesSession")
db = Session.GetDatabase("", "")
db.OpenMail
doc = db.createDocument()
doc.appendItemValue("Form", "Memo");
doc.appendItemValue("Subject","Message from Moi")
doc.appendItemValue("Body","The Body")
doc.appendItemValue("SendTo", Insert Recipient here)
doc.send(1) 
Are you able to successfully run the VB code? Here is my attempt at translating the above VB code:
;UNDEBUGGED - WinBatch Code translation.
;**************************************
; Name: A++ Send Lotus Notes Email VBS Script
; Description:Simple script to send a Lotus Notes email. Can be modified to automate tasks on the server.
; By: Steven Jacobs
;
; This code is copyrighted and has limited warranties.
; Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=8815&lngWId=4  
; for details.    
;**************************************
;Get subject...if no subject, exit 
subj = AskLine("Please enter a subject For your mail memo.","Email Subject Text","Subject")
If subj == "" Then
    Message("Error","You need a subject")
    Exit 
Endif

;Get body text...if no body text, exit 
bdy = AskLine("Please enter text For your body mail memo.","Email Body Text","Body")
If bdy == "" Then
    Message("Error","You need body text")
    Exit 
Endif
    
fName = AskFileName("Please enter the full path For the file","C:\", "*.*",1)
If fName == "" Then
    Message("Error","Empty Path")
	 Exit 
Endif

If !FileExists(fName) Then
    Message("error", "File does Not exist In directory you specified")
    Exit
Endif 

ErrorMode(@off)
s = CreateObject("Notes.NotesSession")
ErrorMode(@cancel)
If s == 0 
    Message( "Notes Session Error.","Could Not Create A Session Of Notes")
    Exit
Endif 
mailserver = s.getenvironmentstring("MailServer",@true) 
mailfile = s.getenvironmentstring("Mailfile",@true)

ErrorMode(@off)
db = s.getdatabase(mailserver,mailfile)
ErrorMode(@cancel)
;See if we can a handle on the mail file
If db == 0 Then
    Message("Error", "Could find or Get a handle on the mail file")
	 s = 0
    Exit 
Endif

doc = db.createdocument
rtitem = doc.createrichtextitem("BODY")
;recips(1) = "xxx@xxx.com"  ????????
;recips(2) = "rrr@rrr.com"  ????????

doc.form = "Memo"
doc.subject = subj
doc.sendto = "@xxx.com" 
doc.copyto = "@yyy.com"
doc.body = bdy
doc.postdate = Date

embeddedobject = rtitem.embedobject(1454,"",fName)
Run(embeddedobject,"");??????????????????

doc.visible = @True
doc.send(@False)

;if we made it this far, alert the user the mail memo has been created and sent
Message( "You message has been created and sent.","Message Sent Notification.")
    
s = 0
db = 0
doc = 0
rtitem = 0
fs = 0
exit


Article ID:   W16650
File Created: 2005:02:18:12:21:46
Last Updated: 2005:02:18:12:21:46