VBA Code (Lotus Notes to Outlook) - Convert

Copper Contributor

Hello Wonderful People,

 

Would anyone have the below VBA code, meant for Lotus Notes, in Outlook? Thank you.

 

Public Sub Create_And_Display_Notes_Email()

Dim NSession As Object 'NotesSession
Dim NUIWorkspace As Object 'NotesUIWorkspace
Dim NMailDb As Object 'NotesDatabase
Dim NDocument As Object 'NotesDocument - the email document
Dim NItem As Object 'NotesItem
Dim NRichTextItem As Object 'NotesRichTextItem
Dim NEmbeddedObject As Object 'NotesEmbeddedObject
Dim ToEmail As String, CCEmail As String, BCCEmail As String, Subject As String, BodyText As String

With ActiveSheet
ToEmail = .Range("C2").Value
CCEmail = .Range("C3").Value
BCCEmail = .Range("C4").Value
Subject = .Range("C5").Value
BodyText = Join(Application.Transpose(.Range("C7", .Cells(.Rows.Count, "C").End(xlUp)).Value), vbCrLf)
End With

'Start a session to Lotus Notes

Set NSession = CreateObject("Notes.NotesSession") 'OLE - late binding only
Set NUIWorkspace = CreateObject("Notes.NotesUIWorkspace")

Set NMailDb = NSession.GetDatabase("", "") 'uses the default database (in Notes.ini)
If Not NMailDb.IsOpen Then NMailDb.OpenMail

'Create new email document

Set NDocument = NMailDb.CreateDocument

With NDocument
.ReplaceItemValue "Form", "Memo"
.ReplaceItemValue "Subject", Subject
.ReplaceItemValue "SendTo", ToEmail
.ReplaceItemValue "CopyTo", CCEmail
.ReplaceItemValue "BlindCopyTo", BCCEmail

'Create a rich text item for the email body text

Set NRichTextItem = .CreateRichTextItem("Body")
With NRichTextItem
.AppendText BodyText
.AddNewLine 2
End With

'Save the email (in Drafts)

.Save False, False, False
End With

'Open the newly created email via the Lotus front-end UI objects, so that user can review it

Set NDocument = NUIWorkspace.EditDocument(True, NDocument)

'Put cursor inside email body text

NDocument.GoToField "Body"

End Sub

0 Replies