Код: Выделить всё
Sub LookForEmail(EmailSubject As String)
Dim objNS As outlook.Namespace: Set objNS = GetNamespace("MAPI")
Dim olFolder As outlook.MAPIFolder
Set olFolder = objNS.GetDefaultFolder(olFolderInbox)
Dim Item As Object
Dim NewMail As MailItem
Dim MailFolder As outlook.Items
Dim sFilter As String
Dim Counter As Integer
sFilter = "@SQL=""http://schemas.microsoft.com/mapi/proptag/0x0037001f"" like '%" & EmailSubject & "%'"
Set MailFolder = olFolder.Items.Restrict(sFilter)
MailFolder.Sort "ReceivedTime", True
For Each Item In MailFolder
If TypeOf Item Is outlook.MailItem Then
Dim oMail As outlook.MailItem: Set oMail = Item
If oMail.Subject = EmailSubject Then
Set NewMail = outlook.CreateItem(olMailItem)
With NewMail
.Display
.HTMLBody = "test" _
& "" & "test2" & "" _
& oMail.ReplyAll.HTMLBody
.To = oMail.SenderEmailAddress
.cc = oMail.cc
.BCC = oMail.BCC
.Subject = oMail.Subject 'add here the code
.Display
End With
Exit For
End If
End If
Next
End Sub
Подробнее здесь: https://stackoverflow.com/questions/789 ... -signature