如何使用文本框的内容从 Access 表单生成电子邮件
How to generate email from Access form using contents of textbox
我有一个带有 'help' 按钮的主窗体,该按钮可以打开一个带有文本框的简单窗体,用户可以使用该文本框提交主窗体中记录的问题。我希望使用 'send' 按钮将用户在文本框中键入的内容通过电子邮件发送给我自己和同事。
我在 Whosebug 上找到了以下代码,除了我无法弄清楚如何让电子邮件正文包含用户在文本框中键入的内容而不是当前代码中的静态文本之外,它可以正常工作。
下面是代码现在的样子:
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
有没有人知道如何做到这一点?
改变
Dim Issue As String
strIssue = Me.ContactMessageBox
...
.Body = "strIssue"
到
Dim strIssue As String
strIssue = Me.ContactMessageBox
...
.Body = strIssue
如果您将变量放在“”之间,那么它会被读取为字符串而不是变量。
我有一个带有 'help' 按钮的主窗体,该按钮可以打开一个带有文本框的简单窗体,用户可以使用该文本框提交主窗体中记录的问题。我希望使用 'send' 按钮将用户在文本框中键入的内容通过电子邮件发送给我自己和同事。
我在 Whosebug 上找到了以下代码,除了我无法弄清楚如何让电子邮件正文包含用户在文本框中键入的内容而不是当前代码中的静态文本之外,它可以正常工作。
下面是代码现在的样子:
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
有没有人知道如何做到这一点?
改变
Dim Issue As String
strIssue = Me.ContactMessageBox
...
.Body = "strIssue"
到
Dim strIssue As String
strIssue = Me.ContactMessageBox
...
.Body = strIssue
如果您将变量放在“”之间,那么它会被读取为字符串而不是变量。