VBA Code (Lotus Notes to Outlook) - Convert

%3CLINGO-SUB%20id%3D%22lingo-sub-1720983%22%20slang%3D%22en-US%22%3EVBA%20Code%20(Lotus%20Notes%20to%20Outlook)%20-%20Convert%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1720983%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20Wonderful%20People%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWould%20anyone%20have%20the%20below%20VBA%20code%2C%20meant%20for%20Lotus%20Notes%2C%20in%20Outlook%3F%20Thank%20you.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPublic%20Sub%20Create_And_Display_Notes_Email()%3C%2FP%3E%3CP%3EDim%20NSession%20As%20Object%20'NotesSession%3CBR%20%2F%3EDim%20NUIWorkspace%20As%20Object%20'NotesUIWorkspace%3CBR%20%2F%3EDim%20NMailDb%20As%20Object%20'NotesDatabase%3CBR%20%2F%3EDim%20NDocument%20As%20Object%20'NotesDocument%20-%20the%20email%20document%3CBR%20%2F%3EDim%20NItem%20As%20Object%20'NotesItem%3CBR%20%2F%3EDim%20NRichTextItem%20As%20Object%20'NotesRichTextItem%3CBR%20%2F%3EDim%20NEmbeddedObject%20As%20Object%20'NotesEmbeddedObject%3CBR%20%2F%3EDim%20ToEmail%20As%20String%2C%20CCEmail%20As%20String%2C%20BCCEmail%20As%20String%2C%20Subject%20As%20String%2C%20BodyText%20As%20String%3CBR%20%2F%3E%3CBR%20%2F%3EWith%20ActiveSheet%3CBR%20%2F%3EToEmail%20%3D%20.Range(%22C2%22).Value%3CBR%20%2F%3ECCEmail%20%3D%20.Range(%22C3%22).Value%3CBR%20%2F%3EBCCEmail%20%3D%20.Range(%22C4%22).Value%3CBR%20%2F%3ESubject%20%3D%20.Range(%22C5%22).Value%3CBR%20%2F%3EBodyText%20%3D%20Join(Application.Transpose(.Range(%22C7%22%2C%20.Cells(.Rows.Count%2C%20%22C%22).End(xlUp)).Value)%2C%20vbCrLf)%3CBR%20%2F%3EEnd%20With%3CBR%20%2F%3E%3CBR%20%2F%3E'Start%20a%20session%20to%20Lotus%20Notes%3CBR%20%2F%3E%3CBR%20%2F%3ESet%20NSession%20%3D%20CreateObject(%22Notes.NotesSession%22)%20'OLE%20-%20late%20binding%20only%3CBR%20%2F%3ESet%20NUIWorkspace%20%3D%20CreateObject(%22Notes.NotesUIWorkspace%22)%3CBR%20%2F%3E%3CBR%20%2F%3ESet%20NMailDb%20%3D%20NSession.GetDatabase(%22%22%2C%20%22%22)%20'uses%20the%20default%20database%20(in%20Notes.ini)%3CBR%20%2F%3EIf%20Not%20NMailDb.IsOpen%20Then%20NMailDb.OpenMail%3CBR%20%2F%3E%3CBR%20%2F%3E'Create%20new%20email%20document%3CBR%20%2F%3E%3CBR%20%2F%3ESet%20NDocument%20%3D%20NMailDb.CreateDocument%3CBR%20%2F%3E%3CBR%20%2F%3EWith%20NDocument%3CBR%20%2F%3E.ReplaceItemValue%20%22Form%22%2C%20%22Memo%22%3CBR%20%2F%3E.ReplaceItemValue%20%22Subject%22%2C%20Subject%3CBR%20%2F%3E.ReplaceItemValue%20%22SendTo%22%2C%20ToEmail%3CBR%20%2F%3E.ReplaceItemValue%20%22CopyTo%22%2C%20CCEmail%3CBR%20%2F%3E.ReplaceItemValue%20%22BlindCopyTo%22%2C%20BCCEmail%3CBR%20%2F%3E%3CBR%20%2F%3E'Create%20a%20rich%20text%20item%20for%20the%20email%20body%20text%3CBR%20%2F%3E%3CBR%20%2F%3ESet%20NRichTextItem%20%3D%20.CreateRichTextItem(%22Body%22)%3CBR%20%2F%3EWith%20NRichTextItem%3CBR%20%2F%3E.AppendText%20BodyText%3CBR%20%2F%3E.AddNewLine%202%3CBR%20%2F%3EEnd%20With%3CBR%20%2F%3E%3CBR%20%2F%3E'Save%20the%20email%20(in%20Drafts)%3CBR%20%2F%3E%3CBR%20%2F%3E.Save%20False%2C%20False%2C%20False%3CBR%20%2F%3EEnd%20With%3CBR%20%2F%3E%3CBR%20%2F%3E'Open%20the%20newly%20created%20email%20via%20the%20Lotus%20front-end%20UI%20objects%2C%20so%20that%20user%20can%20review%20it%3CBR%20%2F%3E%3CBR%20%2F%3ESet%20NDocument%20%3D%20NUIWorkspace.EditDocument(True%2C%20NDocument)%3CBR%20%2F%3E%3CBR%20%2F%3E'Put%20cursor%20inside%20email%20body%20text%3CBR%20%2F%3E%3CBR%20%2F%3ENDocument.GoToField%20%22Body%22%3CBR%20%2F%3E%3CBR%20%2F%3EEnd%20Sub%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1720983%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Highlighted
Occasional 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