'How to generate email from Access form using contents of textbox

I have a main form with a 'help' button which opens a simple form with a textbox that a user can use to submit issues noted with the main form. I would like the contents of what the user types into the textbox to be emailed to myself and a co-worker using a 'send' button.

I found the following code on stackoverflow which works except I can't figure out how to have the body of the email include what the user types into the textbox instead of the static text that's currently in the code.

Here's how the code looks now:

 Private Sub SendEmail_Click()
    Dim olApp As Object
    Dim objMail As Object
    Dim Issue As String
    strIssue = Me.ContactMessageBox
            
   On Error Resume Next 'Keep going if there is an error
   Set olApp = GetObject(, "Outlook.Application") 'See if Outlook is open

   If Err Then 'Outlook is not open
     Set olApp = CreateObject("Outlook.Application") 'Create a new instance
   End If
     'Create e-mail item
     Set objMail = olApp.CreateItem(olMailItem)

  With objMail
    .To = "emailaddress.com"
    .Subject = "Form issue"
    .Body = "strIssue"
    .send
  End With

  MsgBox "Operation completed successfully"

End Sub

Does anyone have ideas about how to do this?



Solution 1:[1]

Change

Dim Issue As String
strIssue = Me.ContactMessageBox   

...

.Body = "strIssue"

to

Dim strIssue As String
strIssue = Me.ContactMessageBox  

...

.Body = strIssue

If you put your variable between "" then it is read as a string instead of the variable.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jens