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 "[email protected]"
.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?
CodePudding user response:
The property you need to read would be PR_LAST_VERB_EXECUTED
(0x10810003
). You are interested in the EXCHIVERB_FORWARD = 104
value. The DASL property name is http://schemas.microsoft.com/mapi/proptag/0x10810003
.
You may also check out the time when it forwarded, see PR_LAST_VERB_EXECUTED_TIME
, the DASL name is http://schemas.microsoft.com/mapi/proptag/0x10820040
.
You may find the Exporting Emails from Parent and SubFolders to Excel using VBA thread helpful.
CodePudding user response:
If you mean Outlook (and Redemption) marks the original message as forwarded before the user actually clicks the Send button on the new message, that is to be expected. Outlook simply disregards the change if the new message is cancelled.