Sub Display()
Dim myMail As Outlook.MailItem
Dim myReply As Outlook.MailItem
Dim numItems As Integer
Dim mySelected As Selection
Dim i As Integer
Dim myText As String
Dim signature As String

signature = Environ("appdata") & "\Microsoft\Signatures\"
If Dir(signature, vbDirectory) <> vbNullString Then
    signature = signature & Dir$(signature & "*.htm")
Else:
    signature = ""
End If
signature = CreateObject("Scripting.FileSystemObject").GetFile(signature).OpenAsTextStream(1, -2).ReadAll
Set mySelected = Outlook.ActiveExplorer.Selection
numItems = mySelected.Count

For i = 1 To numItems
Set myMail = mySelected(1)
Set myReply = myMail.Reply
myText = myMail.Body
myReply.Subject = "RO Finalized WF: Annual Review. Entity"
myText = "Hi All," & vbCrLf & vbCrLf & "Worflow ID:" & vbCrLf & vbCrLf & "infoinfoinfoinfo" & vbCrLf & vbCrLf & "Thanks," & vbCrLf & "Josh" & signature
myReply.HTMLBody = myText & vbCrLf & vbCrLf & myMail.HTMLBody 
Myreply.display
  Set myMail = Nothing
  Set myReply = Nothing
Next
Set mySelected = Nothing
End Sub

上面的代码显示了您当前在Outlook中打开的电子邮件的回复,包括谁发送了它(放在To :)中,其中包含您当前在Outlook中打开的整个电子邮件 .

这是我想要它做的,除了不回复打开的电子邮件,我希望它专门回复电子邮件的主题 . 此外,我希望它包含所有回复包含在Outlook中的内容(分隔每封电子邮件的行,与发件人:发送,:收件人:,CC:,主题:显示上一封电子邮件) . 此外,vbCrLf在MyText之后没有做到这一点 .

我还希望将CC:放在我正在创建的电子邮件的CC中的上一封电子邮件中 .

我不是VBA的专家,并且尽可能多地尝试过 . 感谢您提前的帮助:)

I have found another option and the code is displayed below. 这将填充回复电子邮件,包含我需要的所有内容 except 我的自定义正文 .

Sub Display()

Dim olApp As Outlook.Application
Dim olNs As Namespace
Dim Fldr As MAPIFolder
Dim olMail As Variant
Dim i As Integer

Dim IsExecuted As Boolean

 signature = Environ("appdata") & "\Microsoft\Signatures\"
 If Dir(signature, vbDirectory) <> vbNullString Then
    signature = signature & Dir$(signature & "*.htm")
Else:
    signature = ""
End If
signature = CreateObject("Scripting.FileSystemObject").GetFile(signature).OpenAsTextStream(1, -2).ReadAll
Set olApp = New Outlook.Application
Set olNs = olApp.GetNamespace("MAPI")
Set Fldr = olNs.GetDefaultFolder(olFolderInbox)
IsExecuted = False
For Each olMail In Fldr.Items
If InStr(olMail.Subject, "checklist") <> 0 Then
If Not IsExecuted Then
        With olMail.ReplyAll

    .HTMLBody = "Dear All," & "<br>" & signature


        End With
    IsExecuted = True
    olmail.ReplyAll.Display
End If
End If
Next olMail
End Sub

Solution

Sub Display()
Dim olApp As Outlook.Application
Dim olNs As Namespace
Dim Fldr As MAPIFolder
Dim olMail As Variant
Dim i As Integer
Dim IsExecuted As Boolean
signature = Environ("appdata") & "\Microsoft\Signatures\"
If Dir(signature, vbDirectory) <> vbNullString Then
signature = signature & Dir$(signature & "*.htm")
Else:
signature = ""
End If
signature = CreateObject("Scripting.FileSystemObject").GetFile(signature).OpenAsTextStream(1, -2).ReadAll
Set olApp = New Outlook.Application
Set olNs = olApp.GetNamespace("MAPI")
Set Fldr = olNs.GetDefaultFolder(olFolderInbox)

IsExecuted = False
For Each olMail In Fldr.Items
If InStr(olMail.Subject, "Subject") <> 0 Then
If Not IsExecuted Then

    With olMail.ReplyAll

.HTMLBody = "<p>" & "Dear All," & "</p><br>" & signature & .HTMLBody

.Display
  End With
IsExecuted = True


End If
End If
Next olMail
End Sub