If you are unable to create a new account, please email support@bspsoftware.com

 

Cognos Script Editor: Writing scripts to send email from LNotes automatically

Started by ariqe, 05 May 2007 05:36:18 AM

Previous topic - Next topic

ariqe

Hi,

What:
scripts to attach a zipped file in email (Lotus Notes) and send it automatically via launching the cognos scheduler.

The script:
===============
Option Explicit

Sub SendMessage(SendTo As String, CcTo As String, Subject As String, _
         Body As String, FileToSend As String)
         
   Dim LnSession        As Object
   Dim LnDb             As Object
   Dim LnDoc            As Object
   Dim LnRtItem         As Object
   Dim LnAttachment     As Object
     
   Set LnSession = CreateObject("Notes.NotesSession")
   'You replace the .nsf file mentioned on the next line with your on .nsf file
   Set LnDb = LnSession.GetDatabase("", "C:\Lotus\Notes\Data\MYNAME.nsf")
   Set LnDoc = LnDb.CreateDocument()
   LnDoc.Form = "Memo"
   LnDoc.SendTo = SendTo
   LnDoc.CopyTo = CcTo
   LnDoc.Subject = Subject
   LnDoc.Body = Body
   LnDoc.SaveMessageOnSend = True
   Set LnRtItem = LnDoc.CreateRichTextItem("MyBody")
   Set LnAttachment = LnRtItem.EmbedObject(1454, "", FileToSend)

   Call LnDoc.Send(False)

   Set LnAttachment = Nothing
   Set LnRtItem = Nothing
   Set LnDoc = Nothing
   Set LnDb = Nothing
   Set LnSession = Nothing
 
End Sub


Sub Main()

   Dim Receiver            As String
   Dim CopyTo              As String   
   Dim SubjectText         As String
   Dim BodyText            As String
   Dim AttachFile          As String
   Dim DoFileExistCheck    As String
   Dim DoFileDateCheck     As String


   Receiver = "ADDRESSEE@ADDRESS.COM"
   CopyTo = ""
   SubjectText = "ZIPPED FILE TO YOU"
   BodyText = "ATTACHED IS THE ZIPPED FILE FOR YOUR REFERENCE"
   AttachFile = "\\ZIPPED FILES.ZIP"
   
   Call SendMessage(Receiver, CopyTo, SubjectText, BodyText, AttachFile)
   
End Sub



================

Problem:

The error stops at the line:

Set LnAttachment = LnRtItem.EmbedObject(1454, "", FileToSend)




What has gone wrong ?

Anyone knows how to rectify this/ how to write a script to attach zipped files or any attachment in lotus notes ?

Thanks !!