Hello! This is my first question here at Access World, though I have been scouring the forums for months. I have finally come across a problem that I cannot find the solution to.
I'm creating a database where the user selects certain missing items and enters other information on a single form. When they finished, they click the 'Send Email' button, and an email is generated in Lotus Notes using VBA code (see below). All was well - until they asked to be able to add multiple form entries into one email so the recipient receives 1 email with 10 entries instead of 10 emails with 1 entry.
After brainstorming for a few days, I decided the way I would like to tackle this would be by leaving the email open and using a separate button to 'Add Next Entry'. My hopes is that this would add the new form entry to the same email as the previous entry. The reasoning behind this is to keep the formatting that I've created for the body for each individual form entry. Only problem is, I can't figure out how to tell Access to use the already open email instead of creating a new one. So, I will be using a separate button/sub routine to add the next entry to the email, and then a final entry button that will prepare the email to be sent. Both the 'Next' and 'Last' buttons will have nearly the same coding, just different Body strings because a final line will need added.
Here is the code that I'm using to add the FIRST form entry (i.e. creating the email and adding the first entry). It works perfectly, generating the email and leaving it open for viewing/editing. I just need to know how to change it to add text to the current open document in Lotus Notes instead of creating a new document. Thanks!
I'm creating a database where the user selects certain missing items and enters other information on a single form. When they finished, they click the 'Send Email' button, and an email is generated in Lotus Notes using VBA code (see below). All was well - until they asked to be able to add multiple form entries into one email so the recipient receives 1 email with 10 entries instead of 10 emails with 1 entry.
After brainstorming for a few days, I decided the way I would like to tackle this would be by leaving the email open and using a separate button to 'Add Next Entry'. My hopes is that this would add the new form entry to the same email as the previous entry. The reasoning behind this is to keep the formatting that I've created for the body for each individual form entry. Only problem is, I can't figure out how to tell Access to use the already open email instead of creating a new one. So, I will be using a separate button/sub routine to add the next entry to the email, and then a final entry button that will prepare the email to be sent. Both the 'Next' and 'Last' buttons will have nearly the same coding, just different Body strings because a final line will need added.
Here is the code that I'm using to add the FIRST form entry (i.e. creating the email and adding the first entry). It works perfectly, generating the email and leaving it open for viewing/editing. I just need to know how to change it to add text to the current open document in Lotus Notes instead of creating a new document. Thanks!
Code:
'Set up the objects required for sending email through Lotus Notes
Dim Notes As Object
Dim db As Object
Dim WorkSpace As Object
Dim UIdoc As Object
Dim UserName As String
Dim MailDbName As String
Set Notes = CreateObject("Notes.NotesSession")
UserName = Notes.UserName
MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
Set db = Notes.GetDatabase(vbNullString, MailDbName)
Set WorkSpace = CreateObject("Notes.NotesUIWorkspace")
Call WorkSpace.ComposeDocument(, , "Memo")
Set UIdoc = WorkSpace.CurrentDocument
Dim BodyText As String
Dim APSx As String
Dim ALRx As String
Dim RMx As String
Dim PREMx As String
Dim SDRx As String
Dim AORx As String
Dim BPx As String
Dim MISC1x As String
[Body text removed for your viewing pleasure]
Subject1 = "Subject Here"
'Insert subject text into email
Call UIdoc.GOTOFIELD("Subject")
Call UIdoc.InsertText(Subject1)
'Insert body text into email
Call UIdoc.GOTOFIELD("Body")
Call UIdoc.InsertText(BodyText)
Set Notes = Nothing
Set db = Nothing
Set WorkSpace = Nothing
Set UIdoc = Nothing