Paste Clipboard into Lotus Notes E-mail body

b3ndee46

New Member
Joined
Aug 3, 2023
Messages
2
Office Version
  1. 2019
Platform
  1. Windows
Hi there, I am really new, and already hopeless :)

Can anybody please tell me, why my code is pasting correctly the image from clipboard into e-mail body?
I am trying to code by myself, sometimes I win, sometime I don't :)

I would highly appreciate if anybody could teach me where my logic gone wrong.

Sub OpenNewEmailInNotes()
Dim NotesApp As Object
Dim NotesUIWorkspace As Object
Dim NotesUIDoc As Object
Dim rng As Range
Dim emailBody As String
Set NotesApp = CreateObject("Notes.NotesSession")
Set NotesUIWorkspace = CreateObject("Notes.NotesUIWorkspace")
Set NotesUIDoc = NotesUIWorkspace.ComposeDocument("", "", "Memo")
NotesUIDoc.FieldSetText "EnterSendTo", "Email"
NotesUIDoc.FieldSetText "Subject", "Mreport"
Set rng = ThisWorkbook.ActiveSheet.Range("A1:H20")
ThisWorkbook.Activate
rng.CopyPicture Appearance:=xlScreen, Format:=xlPicture
emailBody = "Report attached" & vbCrLf & "<br><br><img src='cid:clipboard_image'>"
NotesUIDoc.FieldAppendText "Body", emailBody
NotesUIDoc.Paste
Set NotesUIDoc = Nothing
Set NotesUIWorkspace = Nothing
Set NotesApp = Nothing
End Sub

Thank you in advance!
ben
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Try this:
VBA Code:
Public Sub Email_Excel_Cells()

    Dim NSession As Object
    Dim NUIWorkSpace As Object
    Dim NDoc As Object
    Dim NUIdoc As Object
    
    Set NSession = CreateObject("Notes.NotesSession")
    Set NUIWorkSpace = CreateObject("Notes.NotesUIWorkspace")
    
    Set NDoc = NUIWorkSpace.ComposeDocument("", "", "Memo")
    Set NUIdoc = NUIWorkSpace.currentdocument
    
    With NUIdoc
        .FieldSetText "EnterSendTo", "email@address.com, email2@address.com"
        .FieldSetText "EnterCopyTo", "copy@address.com"
        .FieldSetText "Subject", "Mreport"
        .FieldSetText "Body", "Report attached." & String(2, vbCrLf)
        .GotoField "Body"
        ThisWorkbook.ActiveSheet.Range("A1:E19").Copy
        .Paste
        Application.CutCopyMode = False
        '.Send
        '.Close
    End With
    
    Set NUIdoc = Nothing
    Set NDoc = Nothing
    Set NUIWorkSpace = Nothing
    Set NSession = Nothing
    
End Sub
PS Please use VBA code tags - the VBA icon in the message toolbar.
 
Upvote 0
Solution

John_w, You are my hero! :) Thank you!!​

Try this:
VBA Code:
Public Sub Email_Excel_Cells()

    Dim NSession As Object
    Dim NUIWorkSpace As Object
    Dim NDoc As Object
    Dim NUIdoc As Object
   
    Set NSession = CreateObject("Notes.NotesSession")
    Set NUIWorkSpace = CreateObject("Notes.NotesUIWorkspace")
   
    Set NDoc = NUIWorkSpace.ComposeDocument("", "", "Memo")
    Set NUIdoc = NUIWorkSpace.currentdocument
   
    With NUIdoc
        .FieldSetText "EnterSendTo", "email@address.com, email2@address.com"
        .FieldSetText "EnterCopyTo", "copy@address.com"
        .FieldSetText "Subject", "Mreport"
        .FieldSetText "Body", "Report attached." & String(2, vbCrLf)
        .GotoField "Body"
        ThisWorkbook.ActiveSheet.Range("A1:E19").Copy
        .Paste
        Application.CutCopyMode = False
        '.Send
        '.Close
    End With
   
    Set NUIdoc = Nothing
    Set NDoc = Nothing
    Set NUIWorkSpace = Nothing
    Set NSession = Nothing
   
End Sub
PS Please use VBA code tags - the VBA icon in the message toolbar.
 
Upvote 0

Forum statistics

Threads
1,223,884
Messages
6,175,175
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top