VBA Button To Send Email Via Notes 9

MH22

New Member
Joined
Jun 21, 2022
Messages
2
Office Version
  1. 2016
Platform
  1. Windows
Good day everyone,

Looking for a simple way to add a form button onto an Excel 2016 database to simply open IBM Notes 9, fill in the TO and CC fields (with specific email addresses), fill in the SUBJECT and BODY (with specific information), and add my Notes email signature. Then I can hit SEND manually.

I know this should be fairly simple, but having a hard time finding the proper information.

Thanks all!
 

Attachments

  • sendemail.JPG
    sendemail.JPG
    9.4 KB · Views: 7

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Here's what I used to use before we switched over to Outlook, I'm not sure of the version it worked on, but give it a shot. I originally stole it from Send a Range as rich text in body through lotus notes and tweaked it some. This one also copies a range from the worksheet into the email body. If you don't need that, just rem out the section indicated.

VBA Code:
Sub Notes_Email_Excel_Cells()
Dim NSession As Object
Dim NDatabase As Object
Dim NUIWorkSpace As Object
Dim NDoc As Object
Dim NUIdoc As Object
Dim noEmbedObject As Object
Dim noAttachment As Object

Set NSession = CreateObject("Notes.NotesSession")
Set NUIWorkSpace = CreateObject("Notes.NotesUIWorkspace")

'*** see who the user is and get their shared mail database
Set NDatabase = NSession.GETDATABASE("", "")

ReDim Preserve recipient(0)
ReDim Preserve ccto(0)

If Not NDatabase.IsOpen Then
    NDatabase.OPENMAIL
End If
'*** Set the Body text
Body = "What do you want to say?"

'the signature
sig = "Put your signature here"
'Create a new document
st = ThisWorkbook.FullName
Set NDoc = NDatabase.CREATEDOCUMENT
Set noAttachment = NDoc.CreateRichTextItem("st")
Set noEmbedObject = noAttachment.EmbedObject(1454, "", st)

With NDoc
    .SendTo = "recipient list"
    .Subject = "Email Subject"
End With

'Edit the just-created document to copy and paste the Excel cells into it

Set NUIdoc = NUIWorkSpace.EDITDOCUMENT(True, NDoc)

With NUIdoc
    
    'Email body text, delete the old signature
    .FIELDCLEAR ("Body")
    .GOTOFIELD ("Body")
    'insert the top of the body from aboce
    .INSERTTEXT (Body)
    
'↓ Rem out this section if you don't want to copy your worksheet range to the body
    'insert the Excel sheet list copy
    ThisWorkbook.Sheets("Sheet1").Range("A1:D" & ThisWorkbook.Sheets("Sheet1").Range("C" & Rows.Count).End(xlUp).Row).Copy
    .Paste
    Application.CutCopyMode = False
'↑ Rem out to above arrow
    
    .INSERTTEXT (sig)
End With

Set NSession = Nothing
End Sub
 
Upvote 0
Solution
Here's what I used to use before we switched over to Outlook, I'm not sure of the version it worked on, but give it a shot. I originally stole it from Send a Range as rich text in body through lotus notes and tweaked it some. This one also copies a range from the worksheet into the email body. If you don't need that, just rem out the section indicated.

VBA Code:
Sub Notes_Email_Excel_Cells()
Dim NSession As Object
Dim NDatabase As Object
Dim NUIWorkSpace As Object
Dim NDoc As Object
Dim NUIdoc As Object
Dim noEmbedObject As Object
Dim noAttachment As Object

Set NSession = CreateObject("Notes.NotesSession")
Set NUIWorkSpace = CreateObject("Notes.NotesUIWorkspace")

'*** see who the user is and get their shared mail database
Set NDatabase = NSession.GETDATABASE("", "")

ReDim Preserve recipient(0)
ReDim Preserve ccto(0)

If Not NDatabase.IsOpen Then
    NDatabase.OPENMAIL
End If
'*** Set the Body text
Body = "What do you want to say?"

'the signature
sig = "Put your signature here"
'Create a new document
st = ThisWorkbook.FullName
Set NDoc = NDatabase.CREATEDOCUMENT
Set noAttachment = NDoc.CreateRichTextItem("st")
Set noEmbedObject = noAttachment.EmbedObject(1454, "", st)

With NDoc
    .SendTo = "recipient list"
    .Subject = "Email Subject"
End With

'Edit the just-created document to copy and paste the Excel cells into it

Set NUIdoc = NUIWorkSpace.EDITDOCUMENT(True, NDoc)

With NUIdoc
   
    'Email body text, delete the old signature
    .FIELDCLEAR ("Body")
    .GOTOFIELD ("Body")
    'insert the top of the body from aboce
    .INSERTTEXT (Body)
   
'↓ Rem out this section if you don't want to copy your worksheet range to the body
    'insert the Excel sheet list copy
    ThisWorkbook.Sheets("Sheet1").Range("A1:D" & ThisWorkbook.Sheets("Sheet1").Range("C" & Rows.Count).End(xlUp).Row).Copy
    .Paste
    Application.CutCopyMode = False
'↑ Rem out to above arrow
   
    .INSERTTEXT (sig)
End With

Set NSession = Nothing
End Sub
Thank you,

I will play around with it now, greatly appreciated.
 
Upvote 0

Forum statistics

Threads
1,223,898
Messages
6,175,272
Members
452,628
Latest member
dd2

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