I am trying to write a code to find a mail by subject and work with that. When I am putting the exact subject line as string in myItems.Find, it works fine. But if I put the exact same thing in an excel sheet and try to run the code with cell reference its throwing error(Run-time error '-2147352567). Please help me out. Thanks in advance.
Sub SearchMail()
Dim myOlApp As New Outlook.Application
Dim myNameSpace As Outlook.Namespace
Dim sentbox As Outlook.MAPIFolder
Dim myItems As Outlook.Items
Dim myItem As Object
Dim Found As Boolean
Dim mail As Outlook.MailItem
Dim ForwardMail As Outlook.MailItem
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set sentbox = myNameSpace.GetDefaultFolder(olFolderSentMail)
Set myItems = sentbox.Items
'This Works!!
'Set mail = myItems.Find("[Subject] = ""Exact Search text""")
Workbooks("Outlook Mail.xlsm").Sheets("MailingList").Activate
Sheets("MailingList").Select
'This doesn't. Why??
Set mail = myItems.Find("[Subject] = Cells(17,11).Value")
Set ForwardMail = mail.ReplyAll
ForwardMail.Display
End Sub