我有一个脚本,它搜索一个组收件箱子文件夹,并回复主题匹配的第一封电子邮件。然后回复所有邮件。当我填充电子邮件时,我无法将文本添加到电子邮件的其余部分。只能是或。我看到过许多类似问题的响应,显示. HTMLBody ="test"&. HTMLBody作为解决方案,但当调试到达此行时,第二个. HTMLBody显示为"应用程序定义或对象定义的错误"。任何关于是什么导致了这个问题的见解,或者我可以从链中以前的电子邮件中获得信息并以这种方式输入它,我将不胜感激。
谢谢你,
子查找_电子邮件()
Dim olMail As Outlook.MailItem
Dim olReply As Outlook.MailItem
Dim olItems As Outlook.Items
Dim olNS As Namespace
Dim olMailbox As Folder
Dim olFolder As Folder
Dim subFolder As Folder
Dim BodyText As String
Set olNS = GetNamespace("MAPI")
Set olMailbox = olNS.Folders("Group_Inbox")
Set olFolder = olMailbox.Folders("test_Folder")
Set subFolder = olFolder.Folders("test_subFolder")
Set olItems = subFolder.Items
TheDate = Format(Date, "DD-MM-YYYY")
TheDate1 = Format(Date, "YYYY-MM")
TheDate2 = Format(Date, "YYYYMMDD")
TheDate3 = Format(Date, "YYYY")
'查找最近的电子邮件并填充
olItems.Sort "ReceivedTime", True
For i = 1 To olItems.Count
Set olMail = olItems(i)
If InStr(olMail.Subject, "Desired_Subject " & TheDate) > 0 Then
Set olReply = olMail.ReplyAll
With olReply
.Display
.To = "Recipients@gmail.com"
.CC = ""
.Subject = "Test_Subject"
'.Attachments.Add "Document_destination"
.BodyFormat = olFormatHTML
.HTMLBody = "This is a test email sending in Excel" & .HTMLBody ' This is the problem line.
Exit Sub
End With
End If
Next i
End Sub
我知道这可能是因为它是在一个群组收件箱里,这意味着它可能对你有用,但对我可能仍然没用。
"再次感谢,
1条答案
按热度按时间41zrol4v1#
试试这个(我不能测试它,只是一个想法)