Hi everyone,
I have tried for weeks now to add the "Prevent Copying" to an email automatically generated from Excel, via VBA, to Lotus Notes. I have found code examples online, however, I couldn't get it to work on the code below. As I'm relatively new to VBA, this might be something easy, but I just haven't been able to figure it out.
The code below that I'm trying to use should mainly copy and paste an excel range as bitmap in the body of the email, add prevent copying and save it as draft.
Any help would be greatly appreciated!
I have tried for weeks now to add the "Prevent Copying" to an email automatically generated from Excel, via VBA, to Lotus Notes. I have found code examples online, however, I couldn't get it to work on the code below. As I'm relatively new to VBA, this might be something easy, but I just haven't been able to figure it out.
The code below that I'm trying to use should mainly copy and paste an excel range as bitmap in the body of the email, add prevent copying and save it as draft.
Any help would be greatly appreciated!
Code:
Sub Email_Bitmap_Prevent_Copying()
Dim Send_Recipients As Variant
Dim Email_Subject As Variant
Dim Notes As Object
Dim WorkSpace As Object
Dim UIDoc As Object
Dim MailDbName As String
Application.DisplayAlerts = False
Application.ScreenUpdating = False
'********* STARTS EMAIL ON LOTUS NOTES *********
Set Notes = CreateObject("Notes.NotesSession") 'Creates Lotus Notes Session
MailDbName = "email.nsf"
Set Maildb = Notes.GETDATABASE("", MailDbName)
If Maildb.IsOpen = True Then
Else
Maildb.OPENMAIL 'Sets database to default mail database
End If
Set WorkSpace = CreateObject("Notes.NotesUIWorkspace")
Call WorkSpace.ComposeDocument(, , "Memo") 'Creates a memo document (standard email)
Set UIDoc = WorkSpace.CurrentDocument
'********** EMAIL DETAILS **********
Send_Recipients = "EMAIL@EMAIL.COM" 'Recipients
Email_Subject = "Subject: Trying to paste bitmap and add 'prevent copying' on draft" 'Email subject
Call UIDoc.FieldSetText("enterSendTo", Send_Recipients) 'Recipients
Call UIDoc.FieldSetText("Subject", Email_Subject) 'Email subject
Range("B5:C16").CopyPicture (xlBitmap) 'Copies range as bitmap
Call UIDoc.GoToField("Body") 'Goes to the body of the email
Call UIDoc.Paste 'Pastes copied range into the email body as picture
Application.CutCopyMode = False
'UIDoc.ReplaceItemValue "$KeepPrivate", "1" 'Adds prevent copying (**NOT WORKING**)
Application.DisplayAlerts = True
Application.ScreenUpdating = True
MsgBox ("Email successfully created as draft")
Set Send_Recipients = Nothing
Set Email_Subject = Nothing
Set Notes = Nothing
Set WorkSpace = Nothing
Set UIDoc = Nothing
Set MailDbName = Nothing
End Sub