我试图使用文本框中的文本(我将其命名为tx在Excel中)作为正文发送电子邮件。使用Excel文本框中的文本发送Outlook电子邮件 - 错误424:所需的对象
当我运行的代码,有上线的错误:
strbody = tx.Text
错误424:对象所需
Sub SendMail()
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Dim strbody As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
strbody = tx.Text
'On Error Resume Next
With OutMail
.To = "..."
.CC = ""
.BCC = ""
.Subject = Cells(3, 2)
.Body = strbody
.Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
'tx'没有在你的子类中定义,它是一个公共变量吗?什么似乎是问题?请解释什么不如预期! – R3uK
@ R3uK我认为这是工作表上的文本框的名称 – CallumDA
这里有什么问题?当你运行这个程序时,你发送一封空白的电子邮件,是否出错,它什么都不做?如果您的安全设置限制了它,使用'.Send'可能会导致一些问题 - 使用'.Display'替换它以查看哪些内容不工作。 – CLR