Reputation: 39
What I am trying to achieve is very simple, insert the body of an email above the signature in lotus notes. The code I have in vba, when run, opens a new email window in lotus notes pastes in the Subject, SendTo and Body fields. Everything works perfectly, but when the body is inserted it puts the text below my signature. I've done a ton of digging to try and find a solution, but haven't found anything that has worked just right. A few posts I've found suggest removing the signature, pasting the body and then rebuilding the signature into the email--not really the approach i'd like.
Here is my code:
Sub CreateEmail()
Dim Notes As Object
Dim Maildb As Object
Dim objNotesDocument As Object
Dim objNotesField As Object
Set Notes = CreateObject("Notes.NotesSession")
Set Maildb = Notes.GETDATABASE("", "")
Maildb.OPENMAIL
Set objNotesDocument = Maildb.CREATEDOCUMENT
Subject = "Hey look at my email!!"
Set objNotesField = objNotesDocument.APPENDITEMVALUE("Subject", Subject)
Set objNotesField = objNotesDocument.APPENDITEMVALUE("SendTo", GetPrimaryEmail) 'calls a function to return the SendTo
Set objNotesField = objNotesDocument.APPENDITEMVALUE("Body", bodyInfo) 'calls a function to return the body contents.
Set workspace = CreateObject("Notes.NotesUIWorkspace")
Call workspace.EDITDOCUMENT(True, objNotesDocument)
AppActivate "Lotus Notes"
End Sub
Thanks in advance for any help!
Upvotes: 1
Views: 4663
Reputation: 30970
A different approach to set the Body content is to open the new document in edit mode (like you do at the end of your code) and then set cursor to Body field and insert the text. Your code could look like this:
...
Set objNotesField = objNotesDocument.APPENDITEMVALUE("SendTo", GetPrimaryEmail) 'calls a function to return the SendTo
Set workspace = CreateObject("Notes.NotesUIWorkspace")
Call workspace.EDITDOCUMENT(True, objNotesDocument)
Set uidocument = workspace.CurrentDocument
Call uidocument.GotoField("Body")
Call uidocument.InsertText(bodyInfo) 'calls a function to return the body contents.
AppActivate "Lotus Notes"
Upvotes: 4