Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Windows
pEp for Outlook
Commits
78ac1768
Commit
78ac1768
authored
Sep 27, 2021
by
Thomas
Browse files
Adjust algorithm to find patch mail item
parent
c72ce70a
Changes
1
Hide whitespace changes
Inline
Side-by-side
DPE/DistributedPolicyEngine.cs
View file @
78ac1768
...
@@ -143,18 +143,21 @@ namespace pEp.DPE
...
@@ -143,18 +143,21 @@ namespace pEp.DPE
/// <returns>The patch mail item or null if not found.</returns>
/// <returns>The patch mail item or null if not found.</returns>
public
Outlook
.
MailItem
GetPatchMailItem
(
Patch
patch
)
public
Outlook
.
MailItem
GetPatchMailItem
(
Patch
patch
)
{
{
Outlook
.
Folder
inbox
=
Globals
.
ThisAddIn
.
Application
.
Session
.
GetDefaultFolder
(
Outlook
.
OlDefaultFolders
.
olFolderInbox
)
as
Outlook
.
Folder
;
Outlook
.
Folder
inbox
=
null
;
Outlook
.
Items
folderItems
=
inbox
?.
Items
;
Outlook
.
Items
items
=
null
;
if
(
folderItems
?.
Count
>
0
)
try
{
{
Log
.
Verbose
(
"GetPatchMailItem: "
+
folderItems
.
Count
+
" items found."
);
inbox
=
Globals
.
ThisAddIn
.
Application
.
Session
.
GetDefaultFolder
(
Outlook
.
OlDefaultFolders
.
olFolderInbox
)
as
Outlook
.
Folder
;
items
=
inbox
?.
Items
;
try
if
(
items
?.
Count
>
0
)
{
{
Log
.
Verbose
(
"GetPatchMailItem: "
+
items
.
Count
+
" items found in "
+
inbox
.
FolderPath
);
// First filter out older items
// First filter out older items
Outlook
.
Items
filteredInboxItems
=
folderI
tems
.
Restrict
(
"[ReceivedTime] >= '"
+
patch
.
CreationDate
.
ToString
(
"g"
)
+
"'"
);
items
=
i
tems
.
Restrict
(
"[ReceivedTime] >= '"
+
patch
.
CreationDate
.
ToString
(
"g"
)
+
"'"
);
Log
.
Verbose
(
"GetPatchMailItem: Items since receival of patch: "
+
filteredInboxI
tems
?.
Count
??
"0"
);
Log
.
Verbose
(
"GetPatchMailItem: Items since receival of patch: "
+
i
tems
?.
Count
??
"0"
);
Outlook
.
UserDefinedProperties
up
=
inbox
.
UserDefinedProperties
;
Outlook
.
UserDefinedProperties
up
=
inbox
.
UserDefinedProperties
;
if
(
up
.
Find
(
MailItemExtensions
.
USER_PROPERTY_KEY_DPE_PATCH_ID
)
==
null
)
if
(
up
.
Find
(
MailItemExtensions
.
USER_PROPERTY_KEY_DPE_PATCH_ID
)
==
null
)
...
@@ -164,16 +167,34 @@ namespace pEp.DPE
...
@@ -164,16 +167,34 @@ namespace pEp.DPE
// Now find the one with the respective patch id
// Now find the one with the respective patch id
string
filter
=
string
.
Format
(
"[{0}] = '{1}'"
,
MailItemExtensions
.
USER_PROPERTY_KEY_DPE_PATCH_ID
,
patch
.
Id
);
string
filter
=
string
.
Format
(
"[{0}] = '{1}'"
,
MailItemExtensions
.
USER_PROPERTY_KEY_DPE_PATCH_ID
,
patch
.
Id
);
return
filteredInboxItems
.
Find
(
filter
)
as
Outlook
.
MailItem
;
items
=
items
.
Restrict
(
filter
);
if
(
items
.
Count
>
1
)
{
Log
.
Error
(
"GetPatchMailItem: More than one item found with patch id "
+
patch
.
Id
);
}
else
if
(
items
.
Count
<
1
)
{
Log
.
Error
(
"GetPatchMailItem: No item found with patch id "
+
patch
.
Id
);
}
else
{
return
items
[
1
]
as
Outlook
.
MailItem
;
}
}
}
catch
(
Exception
ex
)
else
{
{
Log
.
Error
(
"GetPatchMailItem:
Error occured. "
+
ex
);
Log
.
Verbose
(
"GetPatchMailItem:
No items were found or folder was null."
);
}
}
}
}
else
catch
(
Exception
ex
)
{
Log
.
Error
(
"GetPatchMailItem: Error occured. "
+
ex
);
}
finally
{
{
Log
.
Verbose
(
"GetPatchMailItem: No items were found or folder was null."
);
inbox
=
null
;
items
=
null
;
}
}
return
null
;
return
null
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment