【发布时间】:2019-01-26 01:29:19
【问题描述】:
我正在尝试使用 VBA 在我的 Outlook 收件箱中搜索一个文件夹,并让它回复具有给定主题的最新电子邮件。到目前为止,我有以下代码:
Dim Fldr As Outlook.Folder
Dim olMail As Outlook.MailItem
Dim olReply As Outlook.MailItem
Dim olItems As Outlook.Items
Dim i As Integer
'Dim IsExecuted As Boolean
Set Fldr = Session.GetDefaultFolder(olFolderInbox).folders("Refund Correspondence")
' IsExecuted = False
Set olItems = Fldr.Items
olItems.Sort "[Received]", True
For i = 1 To olItems.Count
Set olMail = olItems(i)
If InStr(olMail.subject, Me.Vendor_Client & " Tax Refund Request - " & Me.Vendor_Name) > 0 Then
' If Not IsExecuted Then
If Not olMail.categories = "Executed" Then
Set olReply = olMail.ReplyAll
With olReply
.BodyFormat = olFormatHTML '''This is where I'm running into trouble
.Display
.To = Me.Vendor_E_mail
.subject = Me.Vendor_Client & " Tax Refund Request - " & Me.Vendor_Name
End With
Exit For
olMail.categories = "Executed"
' IsExecuted = True
End If
End If
Next i
在我从事的其他项目中,我只需要从头开始创建一封电子邮件,并且我已经能够使用 Ron DeBruin 的 RangeToHTML(selection) 使用现有的电子邮件模板将指定范围粘贴到我的电子邮件中包含特定单词和替换功能以用表格替换单词。然而,对于这个项目,我想回复现有的电子邮件链。由于我无法参考电子邮件模板并用要插入的表格替换单词,所以我很茫然。 .bodyFormat = olFormatHTML 确实可以使用我的回复下方的链的其余部分来回复我想要的电子邮件,但我不知道之后如何将我想要的表格粘贴到电子邮件中。我尝试使用 .HTMLBody = rangetohtml(selection) 函数,但这只会创建一封新电子邮件,而链上没有以前的电子邮件。
【问题讨论】: