Email Spacing

CarlStephens

Board Regular
Joined
Sep 25, 2020
Messages
128
Office Version
  1. 2016
Platform
  1. Windows
Hello All,

The below code creates a new email in Lotus Notes, which is a little lengthy but works as required, however, the cursor always finishes at the bottom of the newly created email and I need to review the email from the top.....is there a code that I can add to the below that will mean the email cursor is at the top of the email? Small, I know, but there are lot of emails that I need to review, so this will save a lot of time. Thank you for your time.

Public Sub Create_and_Display_Notes_Email2()

Dim NUIWorkspace As Object
Dim NUIDocument As Object
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

Set NUIWorkspace = CreateObject("Notes.NotesUIWorkspace")

'Create an email using the Notes UI

NUIWorkspace.ComposeDocument , , "Memo"

Do
Set NUIDocument = NUIWorkspace.CurrentDocument
DoEvents
Loop While NUIDocument Is Nothing

With NUIDocument
.FieldSetText "EnterSendTo", ToEmail
.FieldSetText "EnterCopyTo", CCEmail
.FieldSetText "EnterBlindCopyTo", BCCEmail
.FieldSetText "Subject", Subject

.GoToField "Body"
.InsertText BodyText
MsgBox "Go to your emails and you will see that a email has been created with all of the details."
End With
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
VBA Code:
.GoToField "Body"
.InsertText BodyText
.GoToField "Body"
Please use VBA code tags.
Thank you. When I change to your suggestion, per the below, I get a Type Mismatch. Do you know what the fix to this is?

Public Sub Create_and_Display_Notes_Email2()

Dim NUIWorkspace As Object
Dim NUIDocument As Object
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

Set NUIWorkspace = CreateObject("Notes.NotesUIWorkspace")

'Create an email using the Notes UI

NUIWorkspace.ComposeDocument , , "Memo"

Do
Set NUIDocument = NUIWorkspace.CurrentDocument
DoEvents
Loop While NUIDocument Is Nothing

With NUIDocument
.FieldSetText "EnterSendTo", ToEmail
.FieldSetText "EnterCopyTo", CCEmail
.FieldSetText "EnterBlindCopyTo", BCCEmail
.FieldSetText "Subject", Subject

.GoToField "Body"
.InsertText BodyText
.GoToField "Body"
MsgBox "Go to your emails and you will see that a email has been created with all of the details."
End With
 
Upvote 0
Actually, it was something far more laughable....I did not have a record to be able to produce the email, so once I loaded in a valid record, the email creation worked lol. Thank you once again, it is super appreciated.
 
Upvote 0

Forum statistics

Threads
1,214,648
Messages
6,120,726
Members
448,987
Latest member
marion_davis

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