netrixuser
Board Regular
- Joined
- Jan 21, 2019
- Messages
- 77
- Office Version
- 365
- Platform
- Windows
Trying to figure this out and not getting very far.
The snippet of code below works and it is this bit I am trying to adapt to only look at the email if it is unread.
In summary I have two Const statements setting the email address and subject parameters. When the code is run it will look in Outlook, in a specific folder - for emails from a specific sender with a specific subject line.
Within the If statement it does a few things and it sets the email to "read"
I would like to to include a line so that the code above will skip an email if it is already "read" and only work on unread emails.
Tried adding
so it looks like
It doesn't throw an error when run but it must return as false (even though there are unread emails in the folder) as the IF just ends
To re-iterate, the code works if it just looks at the Outlook folder and does the compare in the code - I'd like it to only compare on unread emails
Please shout if you need all the code - I was in a bit of a rush so did some snipping
Thanks in advance for any help
Netrix
The snippet of code below works and it is this bit I am trying to adapt to only look at the email if it is unread.
In summary I have two Const statements setting the email address and subject parameters. When the code is run it will look in Outlook, in a specific folder - for emails from a specific sender with a specific subject line.
Within the If statement it does a few things and it sets the email to "read"
VBA Code:
If ((StrComp(EmailSenderEmailAddress, xxxxxxEmailSenderAddress, vbTextCompare) = 0) And InStr(1, EmailSubject, LCase(xxxxxxEmailSubjectKey), vbTextCompare)) Then
I would like to to include a line so that the code above will skip an email if it is already "read" and only work on unread emails.
Tried adding
VBA Code:
and OutlookMail.unread = True
so it looks like
VBA Code:
If ((StrComp(EmailSenderEmailAddress, VeritasEmailSenderAddress, vbTextCompare) = 0) And InStr(1, EmailSubject, LCase(VeritasEmailSubjectKey), vbTextCompare)) And OutlookMail.UnRead = True Then
It doesn't throw an error when run but it must return as false (even though there are unread emails in the folder) as the IF just ends
To re-iterate, the code works if it just looks at the Outlook folder and does the compare in the code - I'd like it to only compare on unread emails
Please shout if you need all the code - I was in a bit of a rush so did some snipping
Thanks in advance for any help
Netrix