Dr. Demento
Well-known Member
- Joined
- Nov 2, 2010
- Messages
- 618
- Office Version
- 2019
- 2016
- Platform
- Windows
If I need to create a loop that looks thru each item in my Outlook Sent folder and then evaluates it based on who the sender was and whether or not it's the original email (defined by no "RE:" or "FW:" in subject line and it was sent today), how would I go about this??
I tried something like this, but it fails (Error: RTE 287: Application-defined or object-defined error). I didn't include the date test in my example, so if you have some suggestions, I'd be thrilled.
I realize this isn't a full loop, I just need some help with the bolded section. I get the feeling my issue is d/t which variable types I'm using but I'm too inexperienced to know what I should use.
Thanks y'all!
I tried something like this, but it fails (Error: RTE 287: Application-defined or object-defined error). I didn't include the date test in my example, so if you have some suggestions, I'd be thrilled.
Code:
Dim objOutlook As New Outlook.Application ' Early binding
Dim OLNameSpace As Outlook.Namespace
Set OLNameSpace = Outlook.GetNamespace("MAPI")
Dim OLFolder As Outlook.Folder, _
OLFolder_Sent As Outlook.Folder
Set OLFolder = OLNameSpace.GetDefaultFolder(olFolderInbox)
Set OLFolder_Sent = OLNameSpace.GetDefaultFolder(olFolderSentMail)
Dim OLMail As Outlook.MailItem, _
OLMail_items As Outlook.MailItem
For Each OLMail_items In OLFolder_Sent.Items
If InStr(OLMail_items.Subject, "RE:") = 0 And _
InStr(OLMail_items.Subject, "FW:") = 0 And _
[COLOR=#0000ff][B]OLMail_items.SenderEmailAddress[/B][/COLOR] = "[EMAIL="Dr_Demento@aol.com"]Dr_Demento@CompuServe.com[/EMAIL]" then
[I]do stuff
[/I]
Exit For
End If
Next OLMail_items
I realize this isn't a full loop, I just need some help with the bolded section. I get the feeling my issue is d/t which variable types I'm using but I'm too inexperienced to know what I should use.
Thanks y'all!