I'm trying to check if a particular mail item has already been forwarded and if not, to forward that mail item. I'm not having having much luck unfortunately.
This is my code:
Private Sub Forward_Mail(OItem As RDOMail)
Dim oForwardMail As RDOMail
Dim itemTags As Variant
Dim ForwardedTagMissing As Boolean
Dim CCField As String
On Error GoTo Release
itemTags = OItem.GetProps("http://schemas.microsoft.com/mapi/proptag/0x10820040")(0)
ForwardedTagMissing = IsError(itemTags)
If ForwardedTagMissing Then
Set oForwardMail = OItem.Forward
With oForwardMail
.Subject = OItem.Subject
.HTMLBody = OItem.HTMLBody
.Recipients.Add "Test.Email@test.com"
.Display
End With
'Mark unread
OItem.UnRead = False
End If
Set oForwardMail = Nothing
End Sub
The problem with this code is that it sets the mail item to forwarded, even if the mail item hasn't been forwarded yet. Any ideas what I'm doing wrong?