VB Code Issues in Notes 9

Dear All,

We are using the following code for sending email in Lotus Notes 4.5 which is very older version.Suddenly the company change it to latest one IBM Notes 9.0.1.The smae code is not working for sending mail. Pls help me to sort out.I am in very bad position for that

Function EmailSendWithLotus(strReportpath As String, strSubject As String)
Dim noSession As Object
Dim noDatabase As Object
Dim noDocument As Object
Dim obAttachment As Object
Dim EmbedObject As Object
Dim stSubject As Variant
Dim vaRecipient As Variant
Dim vaCCRecipient As Variant
Dim vaMsg As Variant
Dim stAttachment As String
Dim vaRecipient1 As String
Dim vaCCRecipient1 As String
Dim strArray() As String
Dim intCount As Integer

On Error Resume Next

Const EMBED_ATTACHMENT As Long = 1454

vaMsg = “Dear Sir,” & vbCrLf
vaMsg = vaMsg & “” & vbCrLf
vaMsg = vaMsg & “Kindly find the attached energy report " & vbCrLf
vaMsg = vaMsg & “” & vbCrLf
vaMsg = vaMsg & " Thanks & Regards” & vbCrLf
vaMsg = vaMsg & “” & vbCrLf
vaMsg = vaMsg & " Unit-4 & 5 EMS System" & vbCrLf

stSubject = strSubject

'Instantiate the Lotus Notes COM’s Objects.
Set noSession = CreateObject(“Notes.NotesSession”)
Set noDatabase = noSession.GETDATABASE(“”, “”)

'If Lotus Notes is not open then open the mail-part of it.
If noDatabase.IsOpen = False Then
noDatabase.OPENMAIL

End If
If strReportpath = “” Then
Exit Function
End If
stAttachment = strReportpath

'Create the e-mail and the attachment.
Set noDocument = noDatabase.CreateDocument
Set obAttachment = noDocument.CreateRichTextItem(stAttachment)
Set EmbedObject = obAttachment.EmbedObject(EMBED_ATTACHMENT, “”, stAttachment)

If gEmailTo = “” Then
Exit Function
End If

'vaRecipient = gEmailTo
vaCCRecipient = gEmailCC
strArray = Split(gEmailTo, ", ")
vaRecipient = strArray
MsgBox vaRecipient
'MsgBox Split(vaRecipient, ", ")

'Add values to the created e-mail main properties.
With noDocument
.Form = “Memo”
.SendTo = vaRecipient
.Subject = stSubject
.Body = vaMsg
.SaveMessageOnSend = True
End With

'Send the e-mail.
With noDocument
.PostedDate = Now()
.Send 0, vaRecipient
End With
'MsgBox “The e-mail has successfully been created and distributed.”, vbInformation
'Release objects from the memory.
Set EmbedObject = Nothing
Set obAttachment = Nothing
Set noDocument = Nothing
Set noDatabase = Nothing
Set noSession = Nothing
End Function

Subject: Suggestion

put in an error routine that would show what line number the code is erroring out on .

Subject: “The smae code is not working” is next to useless for anyone to help you

I’m going to guess you have not registered the NLSXBE,DLL though, as that was automatically registered in earlier versions, but IBM stopped doing that a few versions back.

http://www-01.ibm.com/support/docview.wss?uid=swg21112239 http://www-01.ibm.com/support/docview.wss?uid=swg21112239

Subject: to put in an error routine – well, here’s a simple one.

Function blah() as datatype

on error goto logError

[the bulk of your code]

exit Function

logError:

Print "Line " & Erl & ": " & Error$

exit Function

end Function