Avatar of gunasekaranmohan
gunasekaranmohan
Flag for United Kingdom of Great Britain and Northern Ireland

asked on 

Notes8 CreateObject("Notes.NotesSession") in C#

Hi,
As Lotus.NotesSession object will require user to enter password and call Initialize function, I have used CreateObject("Notes.NotesSession") to create notes object.     Main reason for using "Notes.NotesSession" instead of Lotus.NotesSession is avoid the password prompt to the user.  "Notes.NotesSession" object will use the current users' notes session.
This logic is working in VB6.0.    I have given the VB code below.

But when try to write same logic in C#, which dll should be added as reference.   How to create object for "Notes.NotesSession" in C#.
Could you please help me.
VB Code:
 
Private Function SendEmail_Notes() As Boolean
 
  Dim strServername As String
  Dim strMailFileName As String
  
  Dim arrAttachments() As String
  Dim intAttachments As Integer
  Dim i As Integer
  
  Dim objNotesMailDb As Object
  Dim objNotesMailDoc As Object
  Dim objNotesRTItem As Object
 
  Set m_objNotesSession = CreateObject("Notes.NOTESSESSION")
  'Bind to mail database
     strServername = m_objNotesSession.GETENVIRONMENTSTRING("MailServer", True)
  strMailFileName = m_objNotesSession.GETENVIRONMENTSTRING("MailFile", True)
  Set objNotesMailDb = m_objNotesSession.GETDATABASE(strServername, strMailFileName)
  If Not objNotesMailDb.ISOPEN = True Then
    objNotesMailDb.OPENMAIL
  End If
  
  Set objNotesMailDoc = objNotesMailDb.CREATEDOCUMENT
  Call objNotesMailDoc.REPLACEITEMVALUE("Form", "Memo")
  Call objNotesMailDoc.APPENDITEMVALUE("SendTo", m_strTo)
  Call objNotesMailDoc.APPENDITEMVALUE("CopyTo", m_strCC)
  Call objNotesMailDoc.REPLACEITEMVALUE("Subject", m_strSubject)
  Call objNotesMailDoc.REPLACEITEMVALUE("PostedDate", Now())
 
  Set objNotesRTItem = objNotesMailDoc.CREATERICHTEXTITEM("Body")
  objNotesRTItem.APPENDTEXT m_strBody
  
  arrAttachments = Split(m_strAttachments, ";")
  intAttachments = UBound(arrAttachments)
  For i = 0 To intAttachments
    If Trim(arrAttachments(i)) <> "" Then
      objNotesRTItem.ADDNEWLINE 2
      objNotesRTItem.EMBEDOBJECT NOTES_EMBED_ATTACHMENT, "", arrAttachments(i)
    End If
  Next
  
  'To set Return Receipt
  If m_blnReturnReceipt Then
    objNotesMailDoc.ReturnReceipt = "1"
  End If
  
  'To set High Importance
  If m_blnHighImportance Then
    Call objNotesMailDoc.REPLACEITEMVALUE("Importance", "1")
  End If
  
  
  'Gets the mail to appear in the Sent items folder
  objNotesMailDoc.SAVEMESSAGEONSEND = True
  Call objNotesMailDoc.REPLACEITEMVALUE("PostedDate", Now())
  
  'Send the document
  objNotesMailDoc.Send 0, Split(m_strTo, ";")
 
  Set objNotesMailDb = Nothing
  Set objNotesMailDoc = Nothing
  Set objNotesRTItem = Nothing
  Set m_objNotesSession = Nothing
 
End Function

Open in new window

Lotus IBMEditors IDEs

Avatar of undefined
Last Comment
gunasekaranmohan

8/22/2022 - Mon