author | Dean |
Fri, 09 Sep 2016 12:46:30 +0200 | |
branch | Experimental_Callback_Events |
changeset 1262 | 92840238d7af |
parent 1261 | e263dd834072 |
child 1271 | 9e2a40ba0157 |
permissions | -rw-r--r-- |
155
cda43d18bcd3
Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents:
144
diff
changeset
|
1 |
using Microsoft.Win32; |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
2 |
using pEp.UI; |
155
cda43d18bcd3
Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents:
144
diff
changeset
|
3 |
using pEpCOMServerAdapterLib; |
cda43d18bcd3
Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents:
144
diff
changeset
|
4 |
using System; |
0 | 5 |
using System.Collections.Generic; |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
6 |
using System.ComponentModel; |
155
cda43d18bcd3
Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents:
144
diff
changeset
|
7 |
using System.Globalization; |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
8 |
using System.IO; |
0 | 9 |
using System.Runtime.InteropServices; |
10 |
using System.Threading; |
|
47 | 11 |
using System.Windows.Forms; |
714
761f853c4c0f
For all Myself identities, calculate user ID using a hash of the windows Environment.UserName;
Dean Looyengoed
parents:
686
diff
changeset
|
12 |
using Office = Microsoft.Office.Core; |
0 | 13 |
using Outlook = Microsoft.Office.Interop.Outlook; |
14 |
||
15 |
namespace pEp |
|
16 |
{ |
|
17 |
public partial class ThisAddIn |
|
18 |
{ |
|
190
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
19 |
#region VSTO generated code |
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
20 |
|
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
21 |
/// <summary> |
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
22 |
/// Required method for Designer support - do not modify |
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
23 |
/// the contents of this method with the code editor. |
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
24 |
/// </summary> |
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
25 |
private void InternalStartup() |
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
26 |
{ |
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
27 |
this.Startup += new System.EventHandler(ThisAddIn_Startup); |
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
28 |
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown); |
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
29 |
} |
201
9e0548fa3942
Code reformatting.
Markus Schaber <markus@pep-security.net>
parents:
191
diff
changeset
|
30 |
|
190
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
31 |
#endregion |
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
32 |
|
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
33 |
private List<KeyValuePair<CultureInfo, string>> _LanguageList = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
34 |
private static pEpEngine _PEPEngine = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
35 |
private Outlook.Folder _PEPStoreRootFolder = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
36 |
private PEPSettings _Settings = null; |
64
5111a11eed7f
replacing TextMessage object with struct
Volker Birk <vb@pep-project.org>
parents:
61
diff
changeset
|
37 |
|
837
727a8fb5a9c0
Decrypt sent items in ActiveSync accounts when the server is trusted.
Dean Looyengoed
parents:
836
diff
changeset
|
38 |
private bool initialized = false; |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
39 |
private FormControlOptions.State lastOptionsState = null; |
837
727a8fb5a9c0
Decrypt sent items in ActiveSync accounts when the server is trusted.
Dean Looyengoed
parents:
836
diff
changeset
|
40 |
private Dictionary<string, string> userIDCache = new Dictionary<string, string>(); |
727a8fb5a9c0
Decrypt sent items in ActiveSync accounts when the server is trusted.
Dean Looyengoed
parents:
836
diff
changeset
|
41 |
private List<WatchedSentFolder> watchedSentFolders = new List<WatchedSentFolder>(); |
942
a033592eff37
Move callbacks to their own class to allow derivation from
Markus Schaber <markus@pep-security.net>
parents:
941
diff
changeset
|
42 |
private CallbackImpl _callbackImpl; |
190
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
43 |
|
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
44 |
/************************************************************** |
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
45 |
* |
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
46 |
* Property Accessors |
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
47 |
* |
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
48 |
*************************************************************/ |
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
49 |
|
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
50 |
/// <summary> |
854
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
51 |
/// Gets the list of languages supported in the pEp engine. |
935
5308aa8494f0
Update language list and trustwords language selection to use latest engine format.
Dean Looyengoed
parents:
933
diff
changeset
|
52 |
/// The list of language includes a key-value pair of the culture as well as a |
5308aa8494f0
Update language list and trustwords language selection to use latest engine format.
Dean Looyengoed
parents:
933
diff
changeset
|
53 |
/// display phrase in the native language for the trustwords. |
5308aa8494f0
Update language list and trustwords language selection to use latest engine format.
Dean Looyengoed
parents:
933
diff
changeset
|
54 |
/// (phrase example: "I want to display the trustwords in English language") |
854
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
55 |
/// </summary> |
935
5308aa8494f0
Update language list and trustwords language selection to use latest engine format.
Dean Looyengoed
parents:
933
diff
changeset
|
56 |
internal List<KeyValuePair<CultureInfo, string>> LanguageList |
854
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
57 |
{ |
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
58 |
get |
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
59 |
{ |
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
60 |
string code; |
935
5308aa8494f0
Update language list and trustwords language selection to use latest engine format.
Dean Looyengoed
parents:
933
diff
changeset
|
61 |
string phrase; |
854
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
62 |
string engineList; |
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
63 |
string[] languages; |
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
64 |
string[] language; |
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
65 |
|
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
66 |
if (this._LanguageList == null) |
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
67 |
{ |
935
5308aa8494f0
Update language list and trustwords language selection to use latest engine format.
Dean Looyengoed
parents:
933
diff
changeset
|
68 |
this._LanguageList = new List<KeyValuePair<CultureInfo, string>>(); |
5308aa8494f0
Update language list and trustwords language selection to use latest engine format.
Dean Looyengoed
parents:
933
diff
changeset
|
69 |
|
5308aa8494f0
Update language list and trustwords language selection to use latest engine format.
Dean Looyengoed
parents:
933
diff
changeset
|
70 |
try |
5308aa8494f0
Update language list and trustwords language selection to use latest engine format.
Dean Looyengoed
parents:
933
diff
changeset
|
71 |
{ |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
72 |
engineList = ThisAddIn.PEPEngine.get_languagelist(); |
935
5308aa8494f0
Update language list and trustwords language selection to use latest engine format.
Dean Looyengoed
parents:
933
diff
changeset
|
73 |
} |
5308aa8494f0
Update language list and trustwords language selection to use latest engine format.
Dean Looyengoed
parents:
933
diff
changeset
|
74 |
catch |
5308aa8494f0
Update language list and trustwords language selection to use latest engine format.
Dean Looyengoed
parents:
933
diff
changeset
|
75 |
{ |
5308aa8494f0
Update language list and trustwords language selection to use latest engine format.
Dean Looyengoed
parents:
933
diff
changeset
|
76 |
engineList = ""; |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
77 |
Log.Error("LanguageList: Failed to get list from engine."); |
935
5308aa8494f0
Update language list and trustwords language selection to use latest engine format.
Dean Looyengoed
parents:
933
diff
changeset
|
78 |
} |
5308aa8494f0
Update language list and trustwords language selection to use latest engine format.
Dean Looyengoed
parents:
933
diff
changeset
|
79 |
|
854
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
80 |
languages = engineList.Split('\n'); |
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
81 |
|
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
82 |
// Go through each language group |
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
83 |
for (int i = 0; i < languages.Length; i++) |
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
84 |
{ |
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
85 |
language = languages[i].Split(','); |
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
86 |
|
935
5308aa8494f0
Update language list and trustwords language selection to use latest engine format.
Dean Looyengoed
parents:
933
diff
changeset
|
87 |
if (language.Length == 3) |
854
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
88 |
{ |
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
89 |
code = language[0].Trim(); |
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
90 |
code = code.Replace("\"", ""); |
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
91 |
|
935
5308aa8494f0
Update language list and trustwords language selection to use latest engine format.
Dean Looyengoed
parents:
933
diff
changeset
|
92 |
phrase = language[2].Trim(); |
5308aa8494f0
Update language list and trustwords language selection to use latest engine format.
Dean Looyengoed
parents:
933
diff
changeset
|
93 |
phrase = phrase.Replace("\"", ""); |
5308aa8494f0
Update language list and trustwords language selection to use latest engine format.
Dean Looyengoed
parents:
933
diff
changeset
|
94 |
|
5308aa8494f0
Update language list and trustwords language selection to use latest engine format.
Dean Looyengoed
parents:
933
diff
changeset
|
95 |
this._LanguageList.Add(new KeyValuePair<CultureInfo, string>(new CultureInfo(code), |
5308aa8494f0
Update language list and trustwords language selection to use latest engine format.
Dean Looyengoed
parents:
933
diff
changeset
|
96 |
phrase)); |
854
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
97 |
} |
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
98 |
} |
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
99 |
} |
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
100 |
|
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
101 |
return (this._LanguageList); |
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
102 |
} |
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
103 |
} |
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
104 |
|
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
105 |
/// <summary> |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
106 |
/// Gets the static pEp engine reference. |
190
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
107 |
/// </summary> |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
108 |
internal static pEpEngine PEPEngine |
64
5111a11eed7f
replacing TextMessage object with struct
Volker Birk <vb@pep-project.org>
parents:
61
diff
changeset
|
109 |
{ |
5111a11eed7f
replacing TextMessage object with struct
Volker Birk <vb@pep-project.org>
parents:
61
diff
changeset
|
110 |
get |
5111a11eed7f
replacing TextMessage object with struct
Volker Birk <vb@pep-project.org>
parents:
61
diff
changeset
|
111 |
{ |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
112 |
if (ThisAddIn._PEPEngine == null) |
64
5111a11eed7f
replacing TextMessage object with struct
Volker Birk <vb@pep-project.org>
parents:
61
diff
changeset
|
113 |
{ |
5111a11eed7f
replacing TextMessage object with struct
Volker Birk <vb@pep-project.org>
parents:
61
diff
changeset
|
114 |
try |
5111a11eed7f
replacing TextMessage object with struct
Volker Birk <vb@pep-project.org>
parents:
61
diff
changeset
|
115 |
{ |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
116 |
ThisAddIn._PEPEngine = new pEpEngine(); |
64
5111a11eed7f
replacing TextMessage object with struct
Volker Birk <vb@pep-project.org>
parents:
61
diff
changeset
|
117 |
} |
467
aeb05f7b2704
Finish initial implementation of global exception handler and sending crash report.
Dean Looyengoed
parents:
465
diff
changeset
|
118 |
catch (Exception ex) |
64
5111a11eed7f
replacing TextMessage object with struct
Volker Birk <vb@pep-project.org>
parents:
61
diff
changeset
|
119 |
{ |
467
aeb05f7b2704
Finish initial implementation of global exception handler and sending crash report.
Dean Looyengoed
parents:
465
diff
changeset
|
120 |
string summaryMessage = Properties.Resources.Message_InitError + " " + |
aeb05f7b2704
Finish initial implementation of global exception handler and sending crash report.
Dean Looyengoed
parents:
465
diff
changeset
|
121 |
Properties.Resources.Message_Reinstall; |
860 | 122 |
Globals.StopAndSendCrashReport(ex, summaryMessage, false, true); |
460
690f8853d7ae
Start to implement the global exception handler in ThisAddIn.
Dean Looyengoed
parents:
455
diff
changeset
|
123 |
|
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
124 |
return (null); |
64
5111a11eed7f
replacing TextMessage object with struct
Volker Birk <vb@pep-project.org>
parents:
61
diff
changeset
|
125 |
} |
5111a11eed7f
replacing TextMessage object with struct
Volker Birk <vb@pep-project.org>
parents:
61
diff
changeset
|
126 |
} |
5111a11eed7f
replacing TextMessage object with struct
Volker Birk <vb@pep-project.org>
parents:
61
diff
changeset
|
127 |
|
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
128 |
return (ThisAddIn._PEPEngine); |
64
5111a11eed7f
replacing TextMessage object with struct
Volker Birk <vb@pep-project.org>
parents:
61
diff
changeset
|
129 |
} |
5111a11eed7f
replacing TextMessage object with struct
Volker Birk <vb@pep-project.org>
parents:
61
diff
changeset
|
130 |
} |
5111a11eed7f
replacing TextMessage object with struct
Volker Birk <vb@pep-project.org>
parents:
61
diff
changeset
|
131 |
|
611 | 132 |
/// <summary> |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
133 |
/// Gets the root folder of the pEp data store. |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
134 |
/// This is primarily used to save unencrypted outlook mail items (mirrors). |
1115
f152a1ffe405
Rename 'pEp' to 'PEPEngine' and 'TempFolder' to 'PEPStoreRootFolder' in ThisAddIn.
Dean
parents:
1114
diff
changeset
|
135 |
/// </summary> |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
136 |
internal Outlook.Folder PEPStoreRootFolder |
1115
f152a1ffe405
Rename 'pEp' to 'PEPEngine' and 'TempFolder' to 'PEPStoreRootFolder' in ThisAddIn.
Dean
parents:
1114
diff
changeset
|
137 |
{ |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
138 |
get { return (this._PEPStoreRootFolder); } |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
139 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
140 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
141 |
/// <summary> |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
142 |
/// Gets the current pEp settings for the add-in. |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
143 |
/// </summary> |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
144 |
internal PEPSettings Settings |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
145 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
146 |
get { return (this._Settings); } |
1090
6234a0b9c6a8
Add PEPSettings class and move all add-in configuration into it.
Dean
parents:
1082
diff
changeset
|
147 |
} |
6234a0b9c6a8
Add PEPSettings class and move all add-in configuration into it.
Dean
parents:
1082
diff
changeset
|
148 |
|
190
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
149 |
/************************************************************** |
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
150 |
* |
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
151 |
* Methods |
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
152 |
* |
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
153 |
*************************************************************/ |
335 | 154 |
|
361
bbe04f85ac03
Updates to the get my identity methods adding the ability to get my identity from a mail item.
Dean Looyengoed
parents:
342
diff
changeset
|
155 |
/// <summary> |
bbe04f85ac03
Updates to the get my identity methods adding the ability to get my identity from a mail item.
Dean Looyengoed
parents:
342
diff
changeset
|
156 |
/// Required override to add ribbon extensions. |
bbe04f85ac03
Updates to the get my identity methods adding the ability to get my identity from a mail item.
Dean Looyengoed
parents:
342
diff
changeset
|
157 |
/// </summary> |
326
2acfe22efee4
Remove pEp ribbon tab and add ribbon for backstage options (disabled for now).
Dean Looyengoed
parents:
307
diff
changeset
|
158 |
protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject() |
2acfe22efee4
Remove pEp ribbon tab and add ribbon for backstage options (disabled for now).
Dean Looyengoed
parents:
307
diff
changeset
|
159 |
{ |
340
ded73ac01f51
Implement the send unencrypted option in the ribbon.
Dean Looyengoed
parents:
335
diff
changeset
|
160 |
return new RibbonCustomizations(); |
335 | 161 |
} |
0 | 162 |
|
361
bbe04f85ac03
Updates to the get my identity methods adding the ability to get my identity from a mail item.
Dean Looyengoed
parents:
342
diff
changeset
|
163 |
/// <summary> |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
164 |
/// Syncronizes the current settings class with the pEp for Outlook instance and the pEp engine. |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
165 |
/// This code should be similar to the Settings_PropertyChanged event. |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
166 |
/// </summary> |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
167 |
private void SyncWithSettings() |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
168 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
169 |
bool exists; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
170 |
Outlook.NameSpace ns = Application.Session; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
171 |
Outlook.Account acct = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
172 |
Outlook.Accounts accounts = ns.Accounts; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
173 |
List<KeyValuePair<CultureInfo, string>> languages; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
174 |
List<PEPSettings.PEPAccountSettings> legacyAcctSettings = new List<PEPSettings.PEPAccountSettings>(); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
175 |
PEPSettings.PEPAccountSettings newAcctSettings; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
176 |
PEPSettings.PEPAccountSettings existingAcctSettings; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
177 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
178 |
try |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
179 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
180 |
if (this._Settings != null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
181 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
182 |
// Extract any legacy account settings which don't have a Type but do have an SMTP address |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
183 |
for (int i = (this._Settings.AccountSettingsList.Count - 1); i >= 0; i--) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
184 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
185 |
existingAcctSettings = this._Settings.AccountSettingsList[i]; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
186 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
187 |
if ((string.IsNullOrEmpty(existingAcctSettings.SMTPAddress) == false) && |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
188 |
(string.IsNullOrEmpty(existingAcctSettings.Type) == true)) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
189 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
190 |
legacyAcctSettings.Add(existingAcctSettings); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
191 |
this._Settings.AccountSettingsList.RemoveAt(i); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
192 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
193 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
194 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
195 |
// Add any new Outlook accounts to the account settings list |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
196 |
for (int i = 1; i <= accounts.Count; i++) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
197 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
198 |
acct = accounts[i]; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
199 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
200 |
if (string.IsNullOrWhiteSpace(acct.SmtpAddress) == false) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
201 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
202 |
newAcctSettings = new PEPSettings.PEPAccountSettings(); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
203 |
newAcctSettings.SMTPAddress = acct.SmtpAddress; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
204 |
newAcctSettings.Type = acct.AccountType.ToString(); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
205 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
206 |
// Check if it already exists in the list |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
207 |
existingAcctSettings = this._Settings.GetAccountSettings(newAcctSettings.SMTPAddress, newAcctSettings.Type); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
208 |
if (existingAcctSettings == null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
209 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
210 |
this._Settings.AccountSettingsList.Add(newAcctSettings); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
211 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
212 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
213 |
else |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
214 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
215 |
Log.Warning("SyncWithSettings: Invalid SMTP address detected, skipping account."); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
216 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
217 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
218 |
Marshal.ReleaseComObject(acct); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
219 |
acct = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
220 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
221 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
222 |
// Remove any entries of the account settings list not in Outlook |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
223 |
// This is needed to skip any entries in the registry that may be invalid and user created |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
224 |
for (int i = (this._Settings.AccountSettingsList.Count - 1); i >= 0; i--) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
225 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
226 |
existingAcctSettings = this._Settings.AccountSettingsList[i]; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
227 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
228 |
// Check if it exists in Outlook |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
229 |
exists = false; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
230 |
for (int j = 1; j <= accounts.Count; j++) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
231 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
232 |
acct = accounts[j]; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
233 |
newAcctSettings = new PEPSettings.PEPAccountSettings(); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
234 |
newAcctSettings.SMTPAddress = acct.SmtpAddress; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
235 |
newAcctSettings.Type = acct.AccountType.ToString(); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
236 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
237 |
if (existingAcctSettings.EqualsByAddressAndType(newAcctSettings)) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
238 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
239 |
exists = true; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
240 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
241 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
242 |
Marshal.ReleaseComObject(acct); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
243 |
acct = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
244 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
245 |
if (exists) { break; } |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
246 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
247 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
248 |
// Delete if necessary |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
249 |
if (exists == false) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
250 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
251 |
this._Settings.AccountSettingsList.RemoveAt(i); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
252 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
253 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
254 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
255 |
// Add and legacy settings back to the validated account settings list |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
256 |
for (int i = 0; i < legacyAcctSettings.Count; i++) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
257 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
258 |
for (int j = 0; j < this._Settings.AccountSettingsList.Count; j++) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
259 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
260 |
existingAcctSettings = this._Settings.AccountSettingsList[j]; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
261 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
262 |
if (legacyAcctSettings[i].EqualsByAddress(existingAcctSettings)) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
263 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
264 |
// Set the store securely setting only |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
265 |
existingAcctSettings.IsSecureStorageEnabled = legacyAcctSettings[i].IsSecureStorageEnabled; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
266 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
267 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
268 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
269 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
270 |
// Sync IsKeyServerUsed with engine |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
271 |
if (this._Settings.IsKeyServerUsed) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
272 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
273 |
ThisAddIn.PEPEngine.start_keyserver_lookup(); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
274 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
275 |
else |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
276 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
277 |
ThisAddIn.PEPEngine.stop_keyserver_lookup(); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
278 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
279 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
280 |
// Sync IsPassiveModeEnabled with engine |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
281 |
ThisAddIn.PEPEngine.passive_mode(this._Settings.IsPassiveModeEnabled); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
282 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
283 |
// Sync IsPEPFolderVisible with Outlook |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
284 |
this.SetPEPStoreRootFolderVisibility(this._Settings.IsPEPFolderVisible); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
285 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
286 |
// Sync IsUnencryptedSubjectEnabled with engine |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
287 |
ThisAddIn.PEPEngine.unencrypted_subject(this._Settings.IsUnencryptedSubjectEnabled); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
288 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
289 |
// Sync IsVerboseLoggingEnabled with engine |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
290 |
ThisAddIn.PEPEngine.verbose_logging(this._Settings.IsVerboseLoggingEnabled); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
291 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
292 |
// Sync TrustwordsCulture with engine |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
293 |
if (this._Settings.TrustwordsCulture != null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
294 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
295 |
// Validate it exists in the engine list |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
296 |
exists = false; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
297 |
languages = this.LanguageList; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
298 |
foreach (KeyValuePair<CultureInfo, string> entry in languages) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
299 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
300 |
if (entry.Key.LCID == this._Settings.TrustwordsCulture.LCID) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
301 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
302 |
exists = true; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
303 |
break; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
304 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
305 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
306 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
307 |
if (exists == false) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
308 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
309 |
// Reset to default |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
310 |
this._Settings.TrustwordsCulture = new CultureInfo(PEPSettings.CULTURE_CODE_DEFAULT); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
311 |
Log.Warning("SyncWithSettings: Invalid TrustwordsCulture detected, setting to default."); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
312 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
313 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
314 |
else |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
315 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
316 |
// Reset to default |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
317 |
this._Settings.TrustwordsCulture = new CultureInfo(PEPSettings.CULTURE_CODE_DEFAULT); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
318 |
Log.Warning("SyncWithSettings: Invalid TrustwordsCulture detected, setting to default."); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
319 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
320 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
321 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
322 |
catch { } |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
323 |
finally |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
324 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
325 |
if (ns != null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
326 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
327 |
Marshal.ReleaseComObject(ns); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
328 |
ns = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
329 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
330 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
331 |
if (acct != null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
332 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
333 |
Marshal.ReleaseComObject(acct); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
334 |
acct = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
335 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
336 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
337 |
if (accounts != null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
338 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
339 |
Marshal.ReleaseComObject(accounts); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
340 |
accounts = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
341 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
342 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
343 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
344 |
return; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
345 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
346 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
347 |
/// <summary> |
626 | 348 |
/// Detects and disables GPG for Windows GpgOL Outlook add-in. |
349 |
/// </summary> |
|
350 |
/// <returns>True if the GpgOL add-in was disabled.</returns> |
|
351 |
private bool DisableGpgOL() |
|
352 |
{ |
|
353 |
bool wasDisabled = false; |
|
830
592efb9cf41d
Handle and log errors in DisableGpgOL method.
Dean Looyengoed
parents:
820
diff
changeset
|
354 |
Office.COMAddIns comAddIns = null; |
626 | 355 |
|
830
592efb9cf41d
Handle and log errors in DisableGpgOL method.
Dean Looyengoed
parents:
820
diff
changeset
|
356 |
try |
626 | 357 |
{ |
830
592efb9cf41d
Handle and log errors in DisableGpgOL method.
Dean Looyengoed
parents:
820
diff
changeset
|
358 |
comAddIns = Globals.ThisAddIn.Application.COMAddIns; |
592efb9cf41d
Handle and log errors in DisableGpgOL method.
Dean Looyengoed
parents:
820
diff
changeset
|
359 |
foreach (Office.COMAddIn addin in comAddIns) |
626 | 360 |
{ |
830
592efb9cf41d
Handle and log errors in DisableGpgOL method.
Dean Looyengoed
parents:
820
diff
changeset
|
361 |
if (string.Equals(addin.Description, "GpgOL - The GnuPG Outlook Plugin", StringComparison.OrdinalIgnoreCase)) |
592efb9cf41d
Handle and log errors in DisableGpgOL method.
Dean Looyengoed
parents:
820
diff
changeset
|
362 |
{ |
592efb9cf41d
Handle and log errors in DisableGpgOL method.
Dean Looyengoed
parents:
820
diff
changeset
|
363 |
addin.Connect = false; |
592efb9cf41d
Handle and log errors in DisableGpgOL method.
Dean Looyengoed
parents:
820
diff
changeset
|
364 |
wasDisabled = true; |
626 | 365 |
|
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
366 |
Log.Info("DisableGpgOL: GpgOL was detected and disabled."); |
830
592efb9cf41d
Handle and log errors in DisableGpgOL method.
Dean Looyengoed
parents:
820
diff
changeset
|
367 |
} |
592efb9cf41d
Handle and log errors in DisableGpgOL method.
Dean Looyengoed
parents:
820
diff
changeset
|
368 |
} |
592efb9cf41d
Handle and log errors in DisableGpgOL method.
Dean Looyengoed
parents:
820
diff
changeset
|
369 |
} |
592efb9cf41d
Handle and log errors in DisableGpgOL method.
Dean Looyengoed
parents:
820
diff
changeset
|
370 |
catch (Exception ex) |
592efb9cf41d
Handle and log errors in DisableGpgOL method.
Dean Looyengoed
parents:
820
diff
changeset
|
371 |
{ |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
372 |
Log.Error("DisableGpgOL: Error trying to disable GpgOL, " + ex.ToString()); |
830
592efb9cf41d
Handle and log errors in DisableGpgOL method.
Dean Looyengoed
parents:
820
diff
changeset
|
373 |
} |
592efb9cf41d
Handle and log errors in DisableGpgOL method.
Dean Looyengoed
parents:
820
diff
changeset
|
374 |
finally |
592efb9cf41d
Handle and log errors in DisableGpgOL method.
Dean Looyengoed
parents:
820
diff
changeset
|
375 |
{ |
592efb9cf41d
Handle and log errors in DisableGpgOL method.
Dean Looyengoed
parents:
820
diff
changeset
|
376 |
if (comAddIns != null) |
592efb9cf41d
Handle and log errors in DisableGpgOL method.
Dean Looyengoed
parents:
820
diff
changeset
|
377 |
{ |
592efb9cf41d
Handle and log errors in DisableGpgOL method.
Dean Looyengoed
parents:
820
diff
changeset
|
378 |
Marshal.ReleaseComObject(comAddIns); |
592efb9cf41d
Handle and log errors in DisableGpgOL method.
Dean Looyengoed
parents:
820
diff
changeset
|
379 |
comAddIns = null; |
626 | 380 |
} |
381 |
} |
|
382 |
||
383 |
return (wasDisabled); |
|
384 |
} |
|
385 |
||
386 |
/// <summary> |
|
384
a0aa034cb7f3
Create and implement new classes for PEPAttachment, PEPIdentity and PEPMessage.
Dean Looyengoed
parents:
378
diff
changeset
|
387 |
/// Registers each personal identity in the pEp engine. |
a0aa034cb7f3
Create and implement new classes for PEPAttachment, PEPIdentity and PEPMessage.
Dean Looyengoed
parents:
378
diff
changeset
|
388 |
/// An identity is determined by each account in Outlook. |
361
bbe04f85ac03
Updates to the get my identity methods adding the ability to get my identity from a mail item.
Dean Looyengoed
parents:
342
diff
changeset
|
389 |
/// </summary> |
910
9bd60ca2c6ac
Add offline support (mostly for Exchange accounts).
Dean Looyengoed
parents:
902
diff
changeset
|
390 |
internal void RegisterMyself() |
0 | 391 |
{ |
919
252172b0fbec
Standardize calls to the Session in ThisAddIn.
Dean Looyengoed
parents:
918
diff
changeset
|
392 |
Outlook.NameSpace ns = this.Application.Session; |
575
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
393 |
Outlook.Account acct = null; |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
394 |
Outlook.Accounts accounts = ns.Accounts; |
576
e0190df007de
Check if current user is null in RegisterMyself method.
Dean Looyengoed
parents:
575
diff
changeset
|
395 |
Outlook.Recipient currUser = null; |
575
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
396 |
pEp_identity_s me; |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
397 |
|
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
398 |
for (int i = 1; i <= accounts.Count; i++) |
0 | 399 |
{ |
575
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
400 |
acct = accounts[i]; |
576
e0190df007de
Check if current user is null in RegisterMyself method.
Dean Looyengoed
parents:
575
diff
changeset
|
401 |
currUser = acct.CurrentUser; |
575
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
402 |
|
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
403 |
me = new pEp_identity_s(); |
14 | 404 |
me.address = acct.SmtpAddress; |
576
e0190df007de
Check if current user is null in RegisterMyself method.
Dean Looyengoed
parents:
575
diff
changeset
|
405 |
me.username = (currUser != null ? currUser.Name : null); |
776
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
406 |
me.user_id = Globals.ThisAddIn.GetUserID(me.address, null); |
12 | 407 |
|
575
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
408 |
// Log information if invalid |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
409 |
if (string.IsNullOrWhiteSpace(me.address)) |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
410 |
{ |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
411 |
Log.Warning("RegisterMyself: Myself[" + i.ToString() + "] doesn't have an address."); |
575
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
412 |
} |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
413 |
|
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
414 |
if (string.IsNullOrWhiteSpace(me.username)) |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
415 |
{ |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
416 |
Log.Warning("RegisterMyself: Myself[" + i.ToString() + "] doesn't have a username."); |
575
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
417 |
} |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
418 |
|
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
419 |
// Call engine |
12 | 420 |
try |
421 |
{ |
|
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
422 |
ThisAddIn.PEPEngine.myself(me); |
12 | 423 |
} |
424 |
catch (COMException ex) |
|
425 |
{ |
|
860 | 426 |
Globals.StopAndSendCrashReport(ex); |
12 | 427 |
} |
575
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
428 |
|
576
e0190df007de
Check if current user is null in RegisterMyself method.
Dean Looyengoed
parents:
575
diff
changeset
|
429 |
// Release objects |
575
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
430 |
if (acct != null) |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
431 |
{ |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
432 |
Marshal.ReleaseComObject(acct); |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
433 |
acct = null; |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
434 |
} |
576
e0190df007de
Check if current user is null in RegisterMyself method.
Dean Looyengoed
parents:
575
diff
changeset
|
435 |
|
e0190df007de
Check if current user is null in RegisterMyself method.
Dean Looyengoed
parents:
575
diff
changeset
|
436 |
if (currUser != null) |
e0190df007de
Check if current user is null in RegisterMyself method.
Dean Looyengoed
parents:
575
diff
changeset
|
437 |
{ |
e0190df007de
Check if current user is null in RegisterMyself method.
Dean Looyengoed
parents:
575
diff
changeset
|
438 |
Marshal.ReleaseComObject(currUser); |
e0190df007de
Check if current user is null in RegisterMyself method.
Dean Looyengoed
parents:
575
diff
changeset
|
439 |
currUser = null; |
e0190df007de
Check if current user is null in RegisterMyself method.
Dean Looyengoed
parents:
575
diff
changeset
|
440 |
} |
575
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
441 |
} |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
442 |
|
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
443 |
// Release objects |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
444 |
if (ns != null) |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
445 |
{ |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
446 |
Marshal.ReleaseComObject(ns); |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
447 |
ns = null; |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
448 |
} |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
449 |
|
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
450 |
if (acct != null) |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
451 |
{ |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
452 |
Marshal.ReleaseComObject(acct); |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
453 |
acct = null; |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
454 |
} |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
455 |
|
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
456 |
if (accounts != null) |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
457 |
{ |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
458 |
Marshal.ReleaseComObject(accounts); |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
459 |
accounts = null; |
0 | 460 |
} |
588
2d12fb5ee4fc
Add developer mode to config and options state.
Dean Looyengoed
parents:
587
diff
changeset
|
461 |
|
576
e0190df007de
Check if current user is null in RegisterMyself method.
Dean Looyengoed
parents:
575
diff
changeset
|
462 |
if (currUser != null) |
e0190df007de
Check if current user is null in RegisterMyself method.
Dean Looyengoed
parents:
575
diff
changeset
|
463 |
{ |
e0190df007de
Check if current user is null in RegisterMyself method.
Dean Looyengoed
parents:
575
diff
changeset
|
464 |
Marshal.ReleaseComObject(currUser); |
e0190df007de
Check if current user is null in RegisterMyself method.
Dean Looyengoed
parents:
575
diff
changeset
|
465 |
currUser = null; |
e0190df007de
Check if current user is null in RegisterMyself method.
Dean Looyengoed
parents:
575
diff
changeset
|
466 |
} |
0 | 467 |
|
384
a0aa034cb7f3
Create and implement new classes for PEPAttachment, PEPIdentity and PEPMessage.
Dean Looyengoed
parents:
378
diff
changeset
|
468 |
return; |
190
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
469 |
} |
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
470 |
|
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
471 |
/// <summary> |
624
a678557a3750
Implement support for force unencrypted in contacts.
Dean Looyengoed
parents:
611
diff
changeset
|
472 |
/// Gets whether the given contact should be forcefully sent unencrypted messages. |
a678557a3750
Implement support for force unencrypted in contacts.
Dean Looyengoed
parents:
611
diff
changeset
|
473 |
/// This will read the value of the user property. |
833
4af5f979b0d8
Support IsDisableProtectionForContactsEnabled in the GetForceUnencrypted(contact) method.
Dean Looyengoed
parents:
831
diff
changeset
|
474 |
/// Note: If IsDisableProtectionForContactsEnabled != true, false will always be returned. |
624
a678557a3750
Implement support for force unencrypted in contacts.
Dean Looyengoed
parents:
611
diff
changeset
|
475 |
/// </summary> |
664
9dcf25b27787
Rename send unencrypted to force unencrypted throughout code.
Dean Looyengoed
parents:
660
diff
changeset
|
476 |
/// <param name="contact">The contact to get the force unencrypted status from.</param> |
9dcf25b27787
Rename send unencrypted to force unencrypted throughout code.
Dean Looyengoed
parents:
660
diff
changeset
|
477 |
/// <returns>True if the mail item is force unencrypted, otherwise false or null.</returns> |
910
9bd60ca2c6ac
Add offline support (mostly for Exchange accounts).
Dean Looyengoed
parents:
902
diff
changeset
|
478 |
internal bool? GetForceUnencrypted(Outlook.ContactItem contact) |
624
a678557a3750
Implement support for force unencrypted in contacts.
Dean Looyengoed
parents:
611
diff
changeset
|
479 |
{ |
833
4af5f979b0d8
Support IsDisableProtectionForContactsEnabled in the GetForceUnencrypted(contact) method.
Dean Looyengoed
parents:
831
diff
changeset
|
480 |
bool? value = null; |
4af5f979b0d8
Support IsDisableProtectionForContactsEnabled in the GetForceUnencrypted(contact) method.
Dean Looyengoed
parents:
831
diff
changeset
|
481 |
Outlook.UserProperties properties; |
4af5f979b0d8
Support IsDisableProtectionForContactsEnabled in the GetForceUnencrypted(contact) method.
Dean Looyengoed
parents:
831
diff
changeset
|
482 |
Outlook.UserProperty up; |
624
a678557a3750
Implement support for force unencrypted in contacts.
Dean Looyengoed
parents:
611
diff
changeset
|
483 |
|
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
484 |
if (this._Settings.IsDisableProtectionForContactsEnabled) |
624
a678557a3750
Implement support for force unencrypted in contacts.
Dean Looyengoed
parents:
611
diff
changeset
|
485 |
{ |
833
4af5f979b0d8
Support IsDisableProtectionForContactsEnabled in the GetForceUnencrypted(contact) method.
Dean Looyengoed
parents:
831
diff
changeset
|
486 |
properties = contact.UserProperties; |
4af5f979b0d8
Support IsDisableProtectionForContactsEnabled in the GetForceUnencrypted(contact) method.
Dean Looyengoed
parents:
831
diff
changeset
|
487 |
up = properties.Find(CryptableMailItem.USER_PROPERTY_KEY_FORCE_UNENCRYPTED); |
4af5f979b0d8
Support IsDisableProtectionForContactsEnabled in the GetForceUnencrypted(contact) method.
Dean Looyengoed
parents:
831
diff
changeset
|
488 |
|
4af5f979b0d8
Support IsDisableProtectionForContactsEnabled in the GetForceUnencrypted(contact) method.
Dean Looyengoed
parents:
831
diff
changeset
|
489 |
if (up == null) |
4af5f979b0d8
Support IsDisableProtectionForContactsEnabled in the GetForceUnencrypted(contact) method.
Dean Looyengoed
parents:
831
diff
changeset
|
490 |
{ |
4af5f979b0d8
Support IsDisableProtectionForContactsEnabled in the GetForceUnencrypted(contact) method.
Dean Looyengoed
parents:
831
diff
changeset
|
491 |
value = null; |
4af5f979b0d8
Support IsDisableProtectionForContactsEnabled in the GetForceUnencrypted(contact) method.
Dean Looyengoed
parents:
831
diff
changeset
|
492 |
} |
4af5f979b0d8
Support IsDisableProtectionForContactsEnabled in the GetForceUnencrypted(contact) method.
Dean Looyengoed
parents:
831
diff
changeset
|
493 |
else |
4af5f979b0d8
Support IsDisableProtectionForContactsEnabled in the GetForceUnencrypted(contact) method.
Dean Looyengoed
parents:
831
diff
changeset
|
494 |
{ |
4af5f979b0d8
Support IsDisableProtectionForContactsEnabled in the GetForceUnencrypted(contact) method.
Dean Looyengoed
parents:
831
diff
changeset
|
495 |
value = up.Value; |
4af5f979b0d8
Support IsDisableProtectionForContactsEnabled in the GetForceUnencrypted(contact) method.
Dean Looyengoed
parents:
831
diff
changeset
|
496 |
} |
624
a678557a3750
Implement support for force unencrypted in contacts.
Dean Looyengoed
parents:
611
diff
changeset
|
497 |
|
833
4af5f979b0d8
Support IsDisableProtectionForContactsEnabled in the GetForceUnencrypted(contact) method.
Dean Looyengoed
parents:
831
diff
changeset
|
498 |
// Release objects |
4af5f979b0d8
Support IsDisableProtectionForContactsEnabled in the GetForceUnencrypted(contact) method.
Dean Looyengoed
parents:
831
diff
changeset
|
499 |
if (properties != null) |
4af5f979b0d8
Support IsDisableProtectionForContactsEnabled in the GetForceUnencrypted(contact) method.
Dean Looyengoed
parents:
831
diff
changeset
|
500 |
{ |
4af5f979b0d8
Support IsDisableProtectionForContactsEnabled in the GetForceUnencrypted(contact) method.
Dean Looyengoed
parents:
831
diff
changeset
|
501 |
Marshal.ReleaseComObject(properties); |
4af5f979b0d8
Support IsDisableProtectionForContactsEnabled in the GetForceUnencrypted(contact) method.
Dean Looyengoed
parents:
831
diff
changeset
|
502 |
properties = null; |
4af5f979b0d8
Support IsDisableProtectionForContactsEnabled in the GetForceUnencrypted(contact) method.
Dean Looyengoed
parents:
831
diff
changeset
|
503 |
} |
624
a678557a3750
Implement support for force unencrypted in contacts.
Dean Looyengoed
parents:
611
diff
changeset
|
504 |
|
833
4af5f979b0d8
Support IsDisableProtectionForContactsEnabled in the GetForceUnencrypted(contact) method.
Dean Looyengoed
parents:
831
diff
changeset
|
505 |
if (up != null) |
4af5f979b0d8
Support IsDisableProtectionForContactsEnabled in the GetForceUnencrypted(contact) method.
Dean Looyengoed
parents:
831
diff
changeset
|
506 |
{ |
4af5f979b0d8
Support IsDisableProtectionForContactsEnabled in the GetForceUnencrypted(contact) method.
Dean Looyengoed
parents:
831
diff
changeset
|
507 |
Marshal.ReleaseComObject(up); |
4af5f979b0d8
Support IsDisableProtectionForContactsEnabled in the GetForceUnencrypted(contact) method.
Dean Looyengoed
parents:
831
diff
changeset
|
508 |
up = null; |
4af5f979b0d8
Support IsDisableProtectionForContactsEnabled in the GetForceUnencrypted(contact) method.
Dean Looyengoed
parents:
831
diff
changeset
|
509 |
} |
624
a678557a3750
Implement support for force unencrypted in contacts.
Dean Looyengoed
parents:
611
diff
changeset
|
510 |
} |
a678557a3750
Implement support for force unencrypted in contacts.
Dean Looyengoed
parents:
611
diff
changeset
|
511 |
|
a678557a3750
Implement support for force unencrypted in contacts.
Dean Looyengoed
parents:
611
diff
changeset
|
512 |
return (value); |
a678557a3750
Implement support for force unencrypted in contacts.
Dean Looyengoed
parents:
611
diff
changeset
|
513 |
} |
a678557a3750
Implement support for force unencrypted in contacts.
Dean Looyengoed
parents:
611
diff
changeset
|
514 |
|
a678557a3750
Implement support for force unencrypted in contacts.
Dean Looyengoed
parents:
611
diff
changeset
|
515 |
/// <summary> |
487
b27803e13913
Add initial methods to support contact-based send unencrypted message.
Dean Looyengoed
parents:
482
diff
changeset
|
516 |
/// Sets whether the given contact should be forcefully sent unencrypted messages. |
b27803e13913
Add initial methods to support contact-based send unencrypted message.
Dean Looyengoed
parents:
482
diff
changeset
|
517 |
/// This will set the value of the user property. |
b27803e13913
Add initial methods to support contact-based send unencrypted message.
Dean Looyengoed
parents:
482
diff
changeset
|
518 |
/// </summary> |
664
9dcf25b27787
Rename send unencrypted to force unencrypted throughout code.
Dean Looyengoed
parents:
660
diff
changeset
|
519 |
/// <param name="contact">The contact to set force unencrypted status for.</param> |
9dcf25b27787
Rename send unencrypted to force unencrypted throughout code.
Dean Looyengoed
parents:
660
diff
changeset
|
520 |
/// <param name="forceUnencrypted">The force unencrypted status to set.</param> |
910
9bd60ca2c6ac
Add offline support (mostly for Exchange accounts).
Dean Looyengoed
parents:
902
diff
changeset
|
521 |
internal void SetForceUnencrypted(Outlook.ContactItem contact, |
9bd60ca2c6ac
Add offline support (mostly for Exchange accounts).
Dean Looyengoed
parents:
902
diff
changeset
|
522 |
bool forceUnencrypted) |
487
b27803e13913
Add initial methods to support contact-based send unencrypted message.
Dean Looyengoed
parents:
482
diff
changeset
|
523 |
{ |
624
a678557a3750
Implement support for force unencrypted in contacts.
Dean Looyengoed
parents:
611
diff
changeset
|
524 |
Outlook.UserProperties properties = contact.UserProperties; |
664
9dcf25b27787
Rename send unencrypted to force unencrypted throughout code.
Dean Looyengoed
parents:
660
diff
changeset
|
525 |
Outlook.UserProperty up = properties.Find(CryptableMailItem.USER_PROPERTY_KEY_FORCE_UNENCRYPTED); |
487
b27803e13913
Add initial methods to support contact-based send unencrypted message.
Dean Looyengoed
parents:
482
diff
changeset
|
526 |
|
b27803e13913
Add initial methods to support contact-based send unencrypted message.
Dean Looyengoed
parents:
482
diff
changeset
|
527 |
if (up == null) |
b27803e13913
Add initial methods to support contact-based send unencrypted message.
Dean Looyengoed
parents:
482
diff
changeset
|
528 |
{ |
664
9dcf25b27787
Rename send unencrypted to force unencrypted throughout code.
Dean Looyengoed
parents:
660
diff
changeset
|
529 |
up = contact.UserProperties.Add(CryptableMailItem.USER_PROPERTY_KEY_FORCE_UNENCRYPTED, |
487
b27803e13913
Add initial methods to support contact-based send unencrypted message.
Dean Looyengoed
parents:
482
diff
changeset
|
530 |
Outlook.OlUserPropertyType.olYesNo, false); |
b27803e13913
Add initial methods to support contact-based send unencrypted message.
Dean Looyengoed
parents:
482
diff
changeset
|
531 |
} |
b27803e13913
Add initial methods to support contact-based send unencrypted message.
Dean Looyengoed
parents:
482
diff
changeset
|
532 |
|
664
9dcf25b27787
Rename send unencrypted to force unencrypted throughout code.
Dean Looyengoed
parents:
660
diff
changeset
|
533 |
up.Value = forceUnencrypted; |
487
b27803e13913
Add initial methods to support contact-based send unencrypted message.
Dean Looyengoed
parents:
482
diff
changeset
|
534 |
|
624
a678557a3750
Implement support for force unencrypted in contacts.
Dean Looyengoed
parents:
611
diff
changeset
|
535 |
// Release objects |
a678557a3750
Implement support for force unencrypted in contacts.
Dean Looyengoed
parents:
611
diff
changeset
|
536 |
if (properties != null) |
487
b27803e13913
Add initial methods to support contact-based send unencrypted message.
Dean Looyengoed
parents:
482
diff
changeset
|
537 |
{ |
624
a678557a3750
Implement support for force unencrypted in contacts.
Dean Looyengoed
parents:
611
diff
changeset
|
538 |
Marshal.ReleaseComObject(properties); |
a678557a3750
Implement support for force unencrypted in contacts.
Dean Looyengoed
parents:
611
diff
changeset
|
539 |
properties = null; |
487
b27803e13913
Add initial methods to support contact-based send unencrypted message.
Dean Looyengoed
parents:
482
diff
changeset
|
540 |
} |
b27803e13913
Add initial methods to support contact-based send unencrypted message.
Dean Looyengoed
parents:
482
diff
changeset
|
541 |
|
488
c654979e27ac
Fix so release isn't done on null objects...
Dean Looyengoed
parents:
487
diff
changeset
|
542 |
if (up != null) |
c654979e27ac
Fix so release isn't done on null objects...
Dean Looyengoed
parents:
487
diff
changeset
|
543 |
{ |
c654979e27ac
Fix so release isn't done on null objects...
Dean Looyengoed
parents:
487
diff
changeset
|
544 |
Marshal.ReleaseComObject(up); |
c654979e27ac
Fix so release isn't done on null objects...
Dean Looyengoed
parents:
487
diff
changeset
|
545 |
up = null; |
c654979e27ac
Fix so release isn't done on null objects...
Dean Looyengoed
parents:
487
diff
changeset
|
546 |
} |
487
b27803e13913
Add initial methods to support contact-based send unencrypted message.
Dean Looyengoed
parents:
482
diff
changeset
|
547 |
|
624
a678557a3750
Implement support for force unencrypted in contacts.
Dean Looyengoed
parents:
611
diff
changeset
|
548 |
return; |
487
b27803e13913
Add initial methods to support contact-based send unencrypted message.
Dean Looyengoed
parents:
482
diff
changeset
|
549 |
} |
b27803e13913
Add initial methods to support contact-based send unencrypted message.
Dean Looyengoed
parents:
482
diff
changeset
|
550 |
|
b27803e13913
Add initial methods to support contact-based send unencrypted message.
Dean Looyengoed
parents:
482
diff
changeset
|
551 |
/// <summary> |
776
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
552 |
/// Gets the pEp user ID for the given address and contact. |
362
867beb89ee19
Move GetUserIDFromAddress from the CryptableMailItem to ThisAddIn.
Dean Looyengoed
parents:
361
diff
changeset
|
553 |
/// </summary> |
867beb89ee19
Move GetUserIDFromAddress from the CryptableMailItem to ThisAddIn.
Dean Looyengoed
parents:
361
diff
changeset
|
554 |
/// <param name="address">The address to get the user ID for.</param> |
776
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
555 |
/// <param name="contact">The contact associated with the address (if any). |
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
556 |
/// This value can be null and is not required for 'myself' user IDs.</param> |
362
867beb89ee19
Move GetUserIDFromAddress from the CryptableMailItem to ThisAddIn.
Dean Looyengoed
parents:
361
diff
changeset
|
557 |
/// <returns>The user ID (Outlook EntryID) for the given address</returns> |
910
9bd60ca2c6ac
Add offline support (mostly for Exchange accounts).
Dean Looyengoed
parents:
902
diff
changeset
|
558 |
internal string GetUserID(string address, |
9bd60ca2c6ac
Add offline support (mostly for Exchange accounts).
Dean Looyengoed
parents:
902
diff
changeset
|
559 |
Outlook.ContactItem contact) |
362
867beb89ee19
Move GetUserIDFromAddress from the CryptableMailItem to ThisAddIn.
Dean Looyengoed
parents:
361
diff
changeset
|
560 |
{ |
511
4a970a30be20
Get rid of unnecessary null/empty check as the structure of the method has changed.
Dean Looyengoed
parents:
510
diff
changeset
|
561 |
string id = null; |
776
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
562 |
Outlook.Folder contactFolder = null; |
507
d0b1586c5235
Add fallback to GetUserID that searches address book entry-by-entry.
Dean Looyengoed
parents:
502
diff
changeset
|
563 |
|
474
a27dbbb2dd88
Add try/catch and error handling around several ThisAddIn methods.
Dean Looyengoed
parents:
473
diff
changeset
|
564 |
try |
362
867beb89ee19
Move GetUserIDFromAddress from the CryptableMailItem to ThisAddIn.
Dean Looyengoed
parents:
361
diff
changeset
|
565 |
{ |
608
38ba4b8308f2
Update GetUserID method to cache IDs, skip Exchange servers and create new contacts if necessary.
Dean Looyengoed
parents:
607
diff
changeset
|
566 |
if (string.IsNullOrEmpty(address) == false) |
569 | 567 |
{ |
608
38ba4b8308f2
Update GetUserID method to cache IDs, skip Exchange servers and create new contacts if necessary.
Dean Looyengoed
parents:
607
diff
changeset
|
568 |
// Search cache |
38ba4b8308f2
Update GetUserID method to cache IDs, skip Exchange servers and create new contacts if necessary.
Dean Looyengoed
parents:
607
diff
changeset
|
569 |
if (id == null) |
511
4a970a30be20
Get rid of unnecessary null/empty check as the structure of the method has changed.
Dean Looyengoed
parents:
510
diff
changeset
|
570 |
{ |
569 | 571 |
try |
474
a27dbbb2dd88
Add try/catch and error handling around several ThisAddIn methods.
Dean Looyengoed
parents:
473
diff
changeset
|
572 |
{ |
608
38ba4b8308f2
Update GetUserID method to cache IDs, skip Exchange servers and create new contacts if necessary.
Dean Looyengoed
parents:
607
diff
changeset
|
573 |
id = this.userIDCache[address]; |
569 | 574 |
} |
575 |
catch |
|
576 |
{ |
|
608
38ba4b8308f2
Update GetUserID method to cache IDs, skip Exchange servers and create new contacts if necessary.
Dean Looyengoed
parents:
607
diff
changeset
|
577 |
id = null; |
510
500cb064737d
Remove try/catch around GetUserID that could hide errors.
Dean Looyengoed
parents:
508
diff
changeset
|
578 |
} |
511
4a970a30be20
Get rid of unnecessary null/empty check as the structure of the method has changed.
Dean Looyengoed
parents:
510
diff
changeset
|
579 |
} |
477 | 580 |
|
714
761f853c4c0f
For all Myself identities, calculate user ID using a hash of the windows Environment.UserName;
Dean Looyengoed
parents:
686
diff
changeset
|
581 |
// Handle myself user ID calculation |
761f853c4c0f
For all Myself identities, calculate user ID using a hash of the windows Environment.UserName;
Dean Looyengoed
parents:
686
diff
changeset
|
582 |
if (id == null) |
761f853c4c0f
For all Myself identities, calculate user ID using a hash of the windows Environment.UserName;
Dean Looyengoed
parents:
686
diff
changeset
|
583 |
{ |
761f853c4c0f
For all Myself identities, calculate user ID using a hash of the windows Environment.UserName;
Dean Looyengoed
parents:
686
diff
changeset
|
584 |
// Check if the address is myself |
910
9bd60ca2c6ac
Add offline support (mostly for Exchange accounts).
Dean Looyengoed
parents:
902
diff
changeset
|
585 |
if (PEPIdentity.GetIsOwnIdentity(address)) |
714
761f853c4c0f
For all Myself identities, calculate user ID using a hash of the windows Environment.UserName;
Dean Looyengoed
parents:
686
diff
changeset
|
586 |
{ |
932 | 587 |
id = "pEp_own_userId"; // Alternatively, null or empty could be used |
714
761f853c4c0f
For all Myself identities, calculate user ID using a hash of the windows Environment.UserName;
Dean Looyengoed
parents:
686
diff
changeset
|
588 |
this.userIDCache[address] = id; |
761f853c4c0f
For all Myself identities, calculate user ID using a hash of the windows Environment.UserName;
Dean Looyengoed
parents:
686
diff
changeset
|
589 |
} |
761f853c4c0f
For all Myself identities, calculate user ID using a hash of the windows Environment.UserName;
Dean Looyengoed
parents:
686
diff
changeset
|
590 |
} |
761f853c4c0f
For all Myself identities, calculate user ID using a hash of the windows Environment.UserName;
Dean Looyengoed
parents:
686
diff
changeset
|
591 |
|
776
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
592 |
// Use a contact EntryID if available |
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
593 |
if ((id == null) && |
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
594 |
(contact != null)) |
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
595 |
{ |
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
596 |
try |
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
597 |
{ |
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
598 |
contactFolder = (Outlook.Folder)contact.Parent; |
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
599 |
id = contactFolder.StoreID.ToUpper() + "_" + contact.EntryID.ToUpper(); |
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
600 |
this.userIDCache[address] = id; |
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
601 |
} |
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
602 |
catch |
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
603 |
{ |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
604 |
Log.Error("GetUserID: Attempted to use contact but failed."); |
776
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
605 |
} |
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
606 |
} |
725
41bac55ab436
Comment out user_id calculation using address books.
Dean Looyengoed
parents:
714
diff
changeset
|
607 |
|
858
c0e7c8cd7227
Support virtual users in UserID calculation (return null if not myself and no contact).
Dean Looyengoed
parents:
854
diff
changeset
|
608 |
/* If no user ID is found at this point, return null. |
c0e7c8cd7227
Support virtual users in UserID calculation (return null if not myself and no contact).
Dean Looyengoed
parents:
854
diff
changeset
|
609 |
* The engine supports 'virtual users' that are only uniquely identified by address. |
c0e7c8cd7227
Support virtual users in UserID calculation (return null if not myself and no contact).
Dean Looyengoed
parents:
854
diff
changeset
|
610 |
* Virtual users will be automatically upgraded if a contact is ever created for the email address. |
c0e7c8cd7227
Support virtual users in UserID calculation (return null if not myself and no contact).
Dean Looyengoed
parents:
854
diff
changeset
|
611 |
*/ |
362
867beb89ee19
Move GetUserIDFromAddress from the CryptableMailItem to ThisAddIn.
Dean Looyengoed
parents:
361
diff
changeset
|
612 |
} |
474
a27dbbb2dd88
Add try/catch and error handling around several ThisAddIn methods.
Dean Looyengoed
parents:
473
diff
changeset
|
613 |
} |
a27dbbb2dd88
Add try/catch and error handling around several ThisAddIn methods.
Dean Looyengoed
parents:
473
diff
changeset
|
614 |
catch (Exception ex) |
a27dbbb2dd88
Add try/catch and error handling around several ThisAddIn methods.
Dean Looyengoed
parents:
473
diff
changeset
|
615 |
{ |
860 | 616 |
Globals.StopAndSendCrashReport(ex); |
362
867beb89ee19
Move GetUserIDFromAddress from the CryptableMailItem to ThisAddIn.
Dean Looyengoed
parents:
361
diff
changeset
|
617 |
} |
776
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
618 |
finally |
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
619 |
{ |
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
620 |
if (contactFolder != null) |
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
621 |
{ |
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
622 |
Marshal.FinalReleaseComObject(contactFolder); |
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
623 |
contactFolder = null; |
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
624 |
} |
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
625 |
} |
362
867beb89ee19
Move GetUserIDFromAddress from the CryptableMailItem to ThisAddIn.
Dean Looyengoed
parents:
361
diff
changeset
|
626 |
|
511
4a970a30be20
Get rid of unnecessary null/empty check as the structure of the method has changed.
Dean Looyengoed
parents:
510
diff
changeset
|
627 |
return (id); |
362
867beb89ee19
Move GetUserIDFromAddress from the CryptableMailItem to ThisAddIn.
Dean Looyengoed
parents:
361
diff
changeset
|
628 |
} |
867beb89ee19
Move GetUserIDFromAddress from the CryptableMailItem to ThisAddIn.
Dean Looyengoed
parents:
361
diff
changeset
|
629 |
|
867beb89ee19
Move GetUserIDFromAddress from the CryptableMailItem to ThisAddIn.
Dean Looyengoed
parents:
361
diff
changeset
|
630 |
/// <summary> |
738
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
631 |
/// Create a new Outlook MailItem from the given PEPMessage and send it. |
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
632 |
/// The sent message will not be processed by the 'Application_ItemSend' event. |
744
278a6ecd7639
Document and implement special handling for Exchange ActiveSync issues during send.
Dean Looyengoed
parents:
743
diff
changeset
|
633 |
/// WARNING: Exchange ActiveSync accounts ignore the deleteAfterSend parameter (always false). |
455
a4158ad1f4b7
Add method to create a new Outlook MailItem and send it without processing.
Dean Looyengoed
parents:
453
diff
changeset
|
634 |
/// </summary> |
a4158ad1f4b7
Add method to create a new Outlook MailItem and send it without processing.
Dean Looyengoed
parents:
453
diff
changeset
|
635 |
/// <param name="message">The message to send.</param> |
475
7a23ec4d8b28
Add deleteAfterSend parameter in SendWithoutProcessing method.
Dean Looyengoed
parents:
474
diff
changeset
|
636 |
/// <param name="deleteAfterSend">Whether the message is deleted after sending (true) or a copy is saved (false).</param> |
910
9bd60ca2c6ac
Add offline support (mostly for Exchange accounts).
Dean Looyengoed
parents:
902
diff
changeset
|
637 |
internal void SendWithoutProcessing(PEPMessage message, |
9bd60ca2c6ac
Add offline support (mostly for Exchange accounts).
Dean Looyengoed
parents:
902
diff
changeset
|
638 |
bool deleteAfterSend) |
455
a4158ad1f4b7
Add method to create a new Outlook MailItem and send it without processing.
Dean Looyengoed
parents:
453
diff
changeset
|
639 |
{ |
a4158ad1f4b7
Add method to create a new Outlook MailItem and send it without processing.
Dean Looyengoed
parents:
453
diff
changeset
|
640 |
Outlook.MailItem newItem; |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
641 |
Globals.ReturnStatus sts; |
455
a4158ad1f4b7
Add method to create a new Outlook MailItem and send it without processing.
Dean Looyengoed
parents:
453
diff
changeset
|
642 |
|
a4158ad1f4b7
Add method to create a new Outlook MailItem and send it without processing.
Dean Looyengoed
parents:
453
diff
changeset
|
643 |
newItem = Application.CreateItem(Outlook.OlItemType.olMailItem); |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
644 |
sts = message.ApplyTo(newItem, false); // Do NOT include internal Header Fields (MAPI properties)! |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
645 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
646 |
if (sts == Globals.ReturnStatus.Success) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
647 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
648 |
// Do not allow TNEF/RTF format with 'winmail.dat' attachment |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
649 |
MAPIHelper.SetProperty(newItem, MAPIProperty.PidLidUseTnef, false); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
650 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
651 |
/* Send |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
652 |
* |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
653 |
* Note: For ActiveSync accounts, the DeleteAfterSubmit property is ignored. |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
654 |
* This means the message will always appear in the sent folder by default. |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
655 |
* The reason for this is unknown. |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
656 |
* |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
657 |
* It's possible this is related to the ActiveSync specification version |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
658 |
* and therefore may behave differently depending on Outlook version. |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
659 |
* More research is needed here. |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
660 |
*/ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
661 |
newItem.DeleteAfterSubmit = deleteAfterSend; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
662 |
((Outlook._MailItem)newItem).Send(); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
663 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
664 |
Marshal.ReleaseComObject(newItem); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
665 |
newItem = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
666 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
667 |
else |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
668 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
669 |
this.PermanentlyDelete(newItem); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
670 |
Marshal.ReleaseComObject(newItem); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
671 |
newItem = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
672 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
673 |
throw new Exception("Failed to create MailItem to send"); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
674 |
} |
455
a4158ad1f4b7
Add method to create a new Outlook MailItem and send it without processing.
Dean Looyengoed
parents:
453
diff
changeset
|
675 |
|
a4158ad1f4b7
Add method to create a new Outlook MailItem and send it without processing.
Dean Looyengoed
parents:
453
diff
changeset
|
676 |
return; |
a4158ad1f4b7
Add method to create a new Outlook MailItem and send it without processing.
Dean Looyengoed
parents:
453
diff
changeset
|
677 |
} |
a4158ad1f4b7
Add method to create a new Outlook MailItem and send it without processing.
Dean Looyengoed
parents:
453
diff
changeset
|
678 |
|
a4158ad1f4b7
Add method to create a new Outlook MailItem and send it without processing.
Dean Looyengoed
parents:
453
diff
changeset
|
679 |
/// <summary> |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
680 |
/// Create a new 'sent' Outlook MailItem and place it in the given store. |
744
278a6ecd7639
Document and implement special handling for Exchange ActiveSync issues during send.
Dean Looyengoed
parents:
743
diff
changeset
|
681 |
/// WARNING: Exchange ActiveSync accounts are not supported by this method. The sent |
278a6ecd7639
Document and implement special handling for Exchange ActiveSync issues during send.
Dean Looyengoed
parents:
743
diff
changeset
|
682 |
/// message will always appear in the drafts folder. |
738
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
683 |
/// </summary> |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
684 |
/// <param name="sendingStore">The store to save the sent message to.</param> |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
685 |
/// <param name="acctSettings">The sending account settings.</param> |
738
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
686 |
/// <param name="sentMessage">The message that is sent.</param> |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
687 |
/// <param name="storedRating">The rating to store to the sent message mail item. |
970
d676bc7cbad6
Store the outgoing color rating for sent messages where possible.
Dean Looyengoed
parents:
935
diff
changeset
|
688 |
/// Will only be set if not undefined (default). Warning: Only use this on trusted servers.</param> |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
689 |
private void CreateNewSentMail(Outlook.Store sendingStore, |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
690 |
PEPSettings.PEPAccountSettings acctSettings, |
970
d676bc7cbad6
Store the outgoing color rating for sent messages where possible.
Dean Looyengoed
parents:
935
diff
changeset
|
691 |
PEPMessage sentMessage, |
d676bc7cbad6
Store the outgoing color rating for sent messages where possible.
Dean Looyengoed
parents:
935
diff
changeset
|
692 |
_pEp_color storedRating = _pEp_color.pEp_rating_undefined) |
738
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
693 |
{ |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
694 |
Int32 messageFlags; |
738
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
695 |
Outlook.MailItem sentMailItem = null; |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
696 |
Outlook.Folder sentFolder = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
697 |
Outlook.NameSpace ns = Application.Session; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
698 |
Outlook.MAPIFolder rootFolder = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
699 |
Outlook.Folders folders = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
700 |
Outlook.Folder folder = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
701 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
702 |
/* The process is: |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
703 |
* 1. Use the Store.GetDefaultFolder(olFolderSentMail) to try to get the default Sent folder. |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
704 |
* However, this can fail for a number of reasons, depending on server and folder configuration. |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
705 |
* 2. As a fallback, search for the Sent folder by matching the Sent folder Entry ID |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
706 |
* However, this can also fail if no Sent folder Entry ID has been recorded. |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
707 |
* 3. As another fallback, search by Folder name ("SENT") for an existing Sent folder |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
708 |
* If found, record the folder's Entry ID. If not, goto point 4. |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
709 |
* 4. If everything of the above fails, create a new Sent folder and record the Entry ID. |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
710 |
*/ |
738
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
711 |
|
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
712 |
try |
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
713 |
{ |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
714 |
if ((sendingStore != null) && |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
715 |
(acctSettings != null) && |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
716 |
(sentMessage != null)) |
1108 | 717 |
{ |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
718 |
rootFolder = sendingStore.GetRootFolder(); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
719 |
if (rootFolder != null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
720 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
721 |
folders = rootFolder.Folders; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
722 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
723 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
724 |
// Step 1 |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
725 |
try |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
726 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
727 |
sentFolder = (Outlook.Folder)sendingStore.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderSentMail); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
728 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
729 |
catch |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
730 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
731 |
if (sentFolder != null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
732 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
733 |
Marshal.ReleaseComObject(sentFolder); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
734 |
sentFolder = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
735 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
736 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
737 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
738 |
// Step 2 |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
739 |
if (sentFolder == null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
740 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
741 |
try |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
742 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
743 |
//Search for folder by EntryID |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
744 |
/* Normally, the way to go would be the following line: |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
745 |
* sentFolder = (Outlook.Folder)ns.GetItemFromID(acctSettings.SentFolderEntryID, sendingStore.StoreID); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
746 |
* However, for some reason, this can come up with the following error: "Could not open the item. Try again." |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
747 |
* Therefore, the below solution is used: |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
748 |
*/ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
749 |
if (folders != null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
750 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
751 |
for (int i = 1; i <= folders.Count; i++) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
752 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
753 |
folder = (Outlook.Folder)folders[i]; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
754 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
755 |
if (folder != null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
756 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
757 |
if ((string.IsNullOrEmpty(folder.EntryID) == false) && |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
758 |
(string.Equals(folder.EntryID, acctSettings.SentFolderEntryID))) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
759 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
760 |
sentFolder = folder; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
761 |
break; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
762 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
763 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
764 |
Marshal.ReleaseComObject(folder); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
765 |
folder = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
766 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
767 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
768 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
769 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
770 |
catch |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
771 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
772 |
if (sentFolder != null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
773 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
774 |
Marshal.ReleaseComObject(sentFolder); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
775 |
sentFolder = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
776 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
777 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
778 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
779 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
780 |
// Step 3 |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
781 |
if (sentFolder == null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
782 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
783 |
try |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
784 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
785 |
//Search for folder by name |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
786 |
if (folders != null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
787 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
788 |
for (int i = 1; i <= folders.Count; i++) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
789 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
790 |
folder = (Outlook.Folder)folders[i]; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
791 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
792 |
if (folder != null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
793 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
794 |
if ((string.IsNullOrEmpty(folder.Name) == false) && |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
795 |
(folder.Name.Trim().StartsWith(Globals.CUSTOM_SENT_FOLDER_NAME, StringComparison.OrdinalIgnoreCase))) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
796 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
797 |
sentFolder = folder; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
798 |
break; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
799 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
800 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
801 |
Marshal.ReleaseComObject(folder); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
802 |
folder = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
803 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
804 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
805 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
806 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
807 |
catch |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
808 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
809 |
if (sentFolder != null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
810 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
811 |
Marshal.ReleaseComObject(sentFolder); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
812 |
sentFolder = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
813 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
814 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
815 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
816 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
817 |
// Step 4 |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
818 |
if (sentFolder == null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
819 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
820 |
try |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
821 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
822 |
// Create folder |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
823 |
if (folders != null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
824 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
825 |
sentFolder = (Outlook.Folder)folders.Add(Globals.CUSTOM_SENT_FOLDER_NAME); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
826 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
827 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
828 |
catch (Exception ex) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
829 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
830 |
if (sentFolder != null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
831 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
832 |
Marshal.ReleaseComObject(sentFolder); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
833 |
sentFolder = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
834 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
835 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
836 |
Log.Error("CreateNewSentMail: No Sent folder found and no new Sent folder could be created because of the following error: " + ex.ToString()); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
837 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
838 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
839 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
840 |
if (sentFolder != null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
841 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
842 |
acctSettings.SentFolderEntryID = sentFolder.EntryID; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
843 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
844 |
// Create the basic sent mail item |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
845 |
sentMailItem = (Outlook.MailItem)sentFolder.Items.Add(Outlook.OlItemType.olMailItem); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
846 |
sentMessage.ApplyTo(sentMailItem, false); // Do NOT include internal Header Fields (MAPI properties)! |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
847 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
848 |
// Set the date and time the mail item was sent |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
849 |
MAPIHelper.SetProperty(sentMailItem, MAPIProperty.PidTagClientSubmitTime, DateTime.Now.ToUniversalTime()); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
850 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
851 |
// Set flags |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
852 |
messageFlags = (System.Int32)MAPIHelper.GetProperty(sentMailItem, MAPIProperty.PidTagMessageFlags); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
853 |
messageFlags &= ~((System.Int32)MAPIPropertyValue.EnumPidTagMessageFlags.mfUnsent); // Clear UNSENT flag -- must be done before save |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
854 |
messageFlags |= ((System.Int32)MAPIPropertyValue.EnumPidTagMessageFlags.mfRead); // Mark as read |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
855 |
MAPIHelper.SetProperty(sentMailItem, MAPIProperty.PidTagMessageFlags, messageFlags); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
856 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
857 |
// Save pEp rating |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
858 |
CryptableMailItem.SetInterpretedProperty(sentMailItem, PEPMessage.XPidNameEncStatus.DASLName, storedRating); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
859 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
860 |
// Save changes to the mail item (must be done last for some properties) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
861 |
sentMailItem.Save(); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
862 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
863 |
/* Attempt to move to the sent folder. |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
864 |
* For ActiveSync accounts, this will fail with the error: |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
865 |
* 'Sorry, Exchange ActiveSync doesn't support what you're trying to do.' |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
866 |
* This is because the .Items.Add(folder) will ignore the specified folder and create in local Drafts. |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
867 |
* Then "Exchange ActiveSync doesn’t support the Drafts folder" so it can't be moved out. |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
868 |
* Even in the Outlook UI a draft cannot be 'dragged' out of the drafts folder. |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
869 |
*/ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
870 |
try |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
871 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
872 |
sentMailItem.Move(sentFolder); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
873 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
874 |
catch { } |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
875 |
} |
738
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
876 |
} |
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
877 |
} |
743
5bad37bca12f
Do not include optional properties when calling .ApplyTo for a sent mail item.
Dean Looyengoed
parents:
738
diff
changeset
|
878 |
catch (Exception ex) |
5bad37bca12f
Do not include optional properties when calling .ApplyTo for a sent mail item.
Dean Looyengoed
parents:
738
diff
changeset
|
879 |
{ |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
880 |
Log.Error("CreateNewSentMail: Error occured, " + ex.ToString()); |
886 | 881 |
throw; |
743
5bad37bca12f
Do not include optional properties when calling .ApplyTo for a sent mail item.
Dean Looyengoed
parents:
738
diff
changeset
|
882 |
} |
738
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
883 |
finally |
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
884 |
{ |
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
885 |
if (sentMailItem != null) |
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
886 |
{ |
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
887 |
Marshal.ReleaseComObject(sentMailItem); |
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
888 |
sentMailItem = null; |
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
889 |
} |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
890 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
891 |
if (ns != null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
892 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
893 |
Marshal.ReleaseComObject(ns); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
894 |
ns = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
895 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
896 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
897 |
if (sentFolder != null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
898 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
899 |
Marshal.ReleaseComObject(sentFolder); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
900 |
sentFolder = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
901 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
902 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
903 |
if (rootFolder != null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
904 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
905 |
Marshal.ReleaseComObject(rootFolder); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
906 |
rootFolder = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
907 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
908 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
909 |
if (folders != null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
910 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
911 |
Marshal.ReleaseComObject(folders); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
912 |
folders = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
913 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
914 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
915 |
if (folder != null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
916 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
917 |
Marshal.ReleaseComObject(folder); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
918 |
folder = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
919 |
} |
738
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
920 |
} |
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
921 |
|
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
922 |
return; |
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
923 |
} |
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
924 |
|
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
925 |
/// <summary> |
745
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
926 |
/// Permanently deletes the given mail item from Outlook. |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
927 |
/// This will also remove any mail item data before save. |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
928 |
/// Therefore, it is safe for handling sensitive data. |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
929 |
/// </summary> |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
930 |
/// <param name="mailItem">The mail item to delete.</param> |
899
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
931 |
/// <param name="mailStore">The known store containing the mail item being deleted. |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
932 |
/// This is used to locate the deleted folder. Leaving empty or setting to null will |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
933 |
/// automatically try to find the store using the mail item itself.</param> |
910
9bd60ca2c6ac
Add offline support (mostly for Exchange accounts).
Dean Looyengoed
parents:
902
diff
changeset
|
934 |
internal void PermanentlyDelete(Outlook.MailItem mailItem, |
9bd60ca2c6ac
Add offline support (mostly for Exchange accounts).
Dean Looyengoed
parents:
902
diff
changeset
|
935 |
Outlook.Store mailStore = null) |
745
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
936 |
{ |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
937 |
bool deleted = false; |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
938 |
string deleteValue; |
899
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
939 |
Outlook.Folder folder = null; |
745
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
940 |
Outlook.Folder deletedFolder = null; |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
941 |
Outlook.MailItem deletedMailItem = null; |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
942 |
Outlook.Attachments attachments = null; |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
943 |
Outlook.Recipients recipients = null; |
899
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
944 |
Outlook.Store store = null; |
745
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
945 |
Outlook.Items items = null; |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
946 |
|
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
947 |
try |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
948 |
{ |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
949 |
/* Remove all relevant data from the mail item |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
950 |
* This is done so it is not saved later where it could be unencrypted |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
951 |
*/ |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
952 |
recipients = mailItem.Recipients; |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
953 |
while (recipients.Count > 0) |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
954 |
{ |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
955 |
recipients.Remove(1); |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
956 |
} |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
957 |
|
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
958 |
mailItem.Subject = ""; |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
959 |
mailItem.BodyFormat = Outlook.OlBodyFormat.olFormatPlain; |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
960 |
mailItem.Body = ""; |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
961 |
mailItem.HTMLBody = ""; |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
962 |
|
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
963 |
attachments = mailItem.Attachments; |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
964 |
while (attachments.Count > 0) |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
965 |
{ |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
966 |
attachments.Remove(1); |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
967 |
} |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
968 |
|
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
969 |
mailItem.Save(); |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
970 |
|
899
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
971 |
// Locate the store for the mailitem if none was given |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
972 |
if (mailStore == null) |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
973 |
{ |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
974 |
try |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
975 |
{ |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
976 |
folder = (Outlook.Folder)mailItem.Parent; |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
977 |
store = folder.Store; |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
978 |
} |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
979 |
catch (Exception ex) |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
980 |
{ |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
981 |
Log.Error("PermanentlyDelete: unable to locate parent store, " + ex.ToString()); |
899
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
982 |
} |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
983 |
finally |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
984 |
{ |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
985 |
// Release objects |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
986 |
if (folder != null) |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
987 |
{ |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
988 |
Marshal.ReleaseComObject(folder); |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
989 |
folder = null; |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
990 |
} |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
991 |
} |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
992 |
} |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
993 |
|
745
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
994 |
/* Move the mail item to the deleted folder then delete (otherwise calling .Delete() will only move to deleted items) |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
995 |
* For ActiveSync accounts, the .Move() call will fail with the error: |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
996 |
* 'Sorry, Exchange ActiveSync doesn't support what you're trying to do.' |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
997 |
*/ |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
998 |
try |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
999 |
{ |
899
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
1000 |
if (mailStore != null) |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
1001 |
{ |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
1002 |
// Use given store |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
1003 |
deletedFolder = (Outlook.Folder)mailStore.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderDeletedItems); |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
1004 |
} |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
1005 |
else |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
1006 |
{ |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
1007 |
// Use calculated store |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
1008 |
deletedFolder = (Outlook.Folder)store.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderDeletedItems); |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
1009 |
} |
745
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1010 |
deletedMailItem = (Outlook.MailItem)mailItem.Move(deletedFolder); |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1011 |
|
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1012 |
/* Change the subject and Save |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1013 |
* If the subject (or another property) is not changed the .Save() call will be ignored |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1014 |
* Calling .Save() is for some reason necessary before .Delete() to work properly |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1015 |
*/ |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1016 |
deletedMailItem.Subject = "pEp"; |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1017 |
deletedMailItem.Save(); |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1018 |
|
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1019 |
// Now that the mail item is in the deleted folder, calling .Delete() will delete permanently |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1020 |
deletedMailItem.Delete(); |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1021 |
deleted = true; |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1022 |
} |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1023 |
catch { } |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1024 |
finally |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1025 |
{ |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1026 |
if (deletedFolder != null) |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1027 |
{ |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1028 |
Marshal.ReleaseComObject(deletedFolder); |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1029 |
deletedFolder = null; |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1030 |
} |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1031 |
|
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1032 |
if (deletedMailItem != null) |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1033 |
{ |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1034 |
Marshal.ReleaseComObject(deletedMailItem); |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1035 |
deletedMailItem = null; |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1036 |
} |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1037 |
} |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1038 |
|
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1039 |
// Try secondary method supporting ActiveSync accounts |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1040 |
if (deleted == false) |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1041 |
{ |
899
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
1042 |
if (mailStore != null) |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
1043 |
{ |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
1044 |
// Use given store |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
1045 |
deletedFolder = (Outlook.Folder)mailStore.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderDeletedItems); |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
1046 |
} |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
1047 |
else |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
1048 |
{ |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
1049 |
// Use calculated store |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
1050 |
deletedFolder = (Outlook.Folder)store.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderDeletedItems); |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
1051 |
} |
745
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1052 |
|
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1053 |
// Tag the item with a user property so it can be located in the deleted folder |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1054 |
deleteValue = "DELETE_" + mailItem.EntryID; |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1055 |
CryptableMailItem.SetUserProperty(mailItem, "DELETE", deleteValue, Outlook.OlUserPropertyType.olText); |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1056 |
mailItem.Save(); |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1057 |
|
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1058 |
// Delete the mail item moving to deleted items folder |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1059 |
mailItem.Delete(); |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1060 |
|
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1061 |
// Permanently delete item by locating in the delete items folder |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1062 |
items = deletedFolder.Items; |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1063 |
for (int i = 1; i <= items.Count; i++) |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1064 |
{ |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1065 |
deletedMailItem = items[i]; |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1066 |
|
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1067 |
// Check if the property exists |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1068 |
if ((string)CryptableMailItem.GetUserProperty(deletedMailItem, "DELETE", "") == deleteValue) |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1069 |
{ |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1070 |
deletedMailItem.Delete(); |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1071 |
deleted = true; |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1072 |
break; |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1073 |
} |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1074 |
|
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1075 |
Marshal.ReleaseComObject(deletedMailItem); |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1076 |
deletedMailItem = null; |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1077 |
} |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1078 |
} |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1079 |
} |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1080 |
catch (Exception ex) |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1081 |
{ |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1082 |
Log.Error("PermanentlyDelete: Failed, " + ex.ToString()); |
745
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1083 |
} |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1084 |
finally |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1085 |
{ |
899
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
1086 |
if (folder != null) |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
1087 |
{ |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
1088 |
Marshal.ReleaseComObject(folder); |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
1089 |
folder = null; |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
1090 |
} |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
1091 |
|
745
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1092 |
if (deletedFolder != null) |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1093 |
{ |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1094 |
Marshal.ReleaseComObject(deletedFolder); |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1095 |
deletedFolder = null; |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1096 |
} |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1097 |
|
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1098 |
if (deletedMailItem != null) |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1099 |
{ |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1100 |
Marshal.ReleaseComObject(deletedMailItem); |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1101 |
deletedMailItem = null; |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1102 |
} |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1103 |
|
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1104 |
if (attachments != null) |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1105 |
{ |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1106 |
Marshal.ReleaseComObject(attachments); |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1107 |
attachments = null; |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1108 |
} |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1109 |
|
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1110 |
if (recipients != null) |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1111 |
{ |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1112 |
Marshal.ReleaseComObject(recipients); |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1113 |
recipients = null; |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1114 |
} |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1115 |
|
899
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
1116 |
if (store != null) |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
1117 |
{ |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
1118 |
Marshal.ReleaseComObject(store); |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
1119 |
store = null; |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
1120 |
} |
376310f19559
Automatically detect the store in PermanentlyDelete if none was given.
Dean Looyengoed
parents:
892
diff
changeset
|
1121 |
|
745
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1122 |
if (items != null) |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1123 |
{ |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1124 |
Marshal.ReleaseComObject(items); |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1125 |
items = null; |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1126 |
} |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1127 |
} |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1128 |
|
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1129 |
return; |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1130 |
} |
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1131 |
|
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
1132 |
/// <summary> |
671
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1133 |
/// Gets whether the given account is trusted (on the account whitelist). |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1134 |
/// Character case and whitespace is ignored during comparison. |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1135 |
/// </summary> |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1136 |
/// <param name="address">The address of the account.</param> |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1137 |
/// <returns>True if the account with the given address is trusted by default (on the whitelist), otherwise false.</returns> |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1138 |
private bool GetIsAccountTrusted(string address) |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1139 |
{ |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1140 |
bool isTrusted = false; |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1141 |
string searchAddress = address.ToUpper().Trim(); |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1142 |
string searchDomain = searchAddress.Contains("@") ? searchAddress.Substring(searchAddress.LastIndexOf("@")) : null; |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1143 |
string whitelistAccount; |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1144 |
|
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1145 |
for (int i = 0; i < this._Settings.AccountWhitelist.Length; i++) |
671
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1146 |
{ |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1147 |
whitelistAccount = this._Settings.AccountWhitelist[i].ToUpper().Trim(); |
671
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1148 |
|
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1149 |
// Check for exact match |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1150 |
if (searchAddress == whitelistAccount) |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1151 |
{ |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1152 |
isTrusted = true; |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1153 |
break; |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1154 |
} |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1155 |
|
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1156 |
// Check for domain match |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1157 |
if ((searchDomain != null) && |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1158 |
whitelistAccount.StartsWith("@") && |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1159 |
(searchDomain == whitelistAccount)) |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1160 |
{ |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1161 |
isTrusted = true; |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1162 |
break; |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1163 |
} |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1164 |
} |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1165 |
|
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1166 |
return (isTrusted); |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1167 |
} |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1168 |
|
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1169 |
/// <summary> |
820
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1170 |
/// Writes the pEp required Outlook options to the registry. |
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1171 |
/// </summary> |
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1172 |
private void SetOutlookRegistryOptions() |
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1173 |
{ |
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1174 |
try |
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1175 |
{ |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1176 |
using (RegistryKey key1 = Registry.CurrentUser.OpenSubKey(PEPSettings.REG_KEY_SOFTWARE)) |
820
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1177 |
{ |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1178 |
using (RegistryKey keyOffice = key1.OpenSubKey(PEPSettings.REG_KEY_MICROSOFT_OFFICE)) |
820
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1179 |
{ |
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1180 |
/* Outlook versions |
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1181 |
* "12" Outlook 2007 |
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1182 |
* "14" Outlook 2010 |
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1183 |
* "15" Outlook 2013 |
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1184 |
* "16" Outlook 2016 |
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1185 |
*/ |
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1186 |
using (RegistryKey keyInternationalOptions = keyOffice.OpenSubKey(Application.Version.Substring(0, 2) + ".0\\Outlook\\Options\\MSHTML\\International", true)) |
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1187 |
{ |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1188 |
keyInternationalOptions.SetValue(PEPSettings.REG_NAME_DEFAULT_CODEPAGE_OUT, (Int32)65001); // UTF-8 |
820
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1189 |
} |
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1190 |
} |
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1191 |
} |
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1192 |
} |
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1193 |
catch (Exception ex) |
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1194 |
{ |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1195 |
Log.Error("SetOutlookRegistryOptions: Failed to set options, " + ex.ToString()); |
820
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1196 |
} |
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1197 |
|
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1198 |
return; |
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1199 |
} |
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1200 |
|
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1201 |
/// <summary> |
203
44dac4bb337a
Complete the state management in both the options form and this add-in.
Dean Looyengoed
parents:
201
diff
changeset
|
1202 |
/// Copies any necessary data from the given options form state back into this add-ins current state. |
44dac4bb337a
Complete the state management in both the options form and this add-in.
Dean Looyengoed
parents:
201
diff
changeset
|
1203 |
/// The registry is also updated by this method. |
44dac4bb337a
Complete the state management in both the options form and this add-in.
Dean Looyengoed
parents:
201
diff
changeset
|
1204 |
/// </summary> |
44dac4bb337a
Complete the state management in both the options form and this add-in.
Dean Looyengoed
parents:
201
diff
changeset
|
1205 |
/// <param name="state">The state to copy data from.</param> |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1206 |
internal void SetOptionsState(FormControlOptions.State state) |
203
44dac4bb337a
Complete the state management in both the options form and this add-in.
Dean Looyengoed
parents:
201
diff
changeset
|
1207 |
{ |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1208 |
bool isBlacklisted; |
839 | 1209 |
string fpr1; |
1210 |
string fpr2; |
|
1211 |
string[] blacklist; |
|
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1212 |
PEPSettings.PEPAccountSettings acctSettings; |
839 | 1213 |
|
203
44dac4bb337a
Complete the state management in both the options form and this add-in.
Dean Looyengoed
parents:
201
diff
changeset
|
1214 |
if (state != null) |
44dac4bb337a
Complete the state management in both the options form and this add-in.
Dean Looyengoed
parents:
201
diff
changeset
|
1215 |
{ |
839 | 1216 |
// Remove any fingerprints from blacklist |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1217 |
try |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1218 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1219 |
blacklist = ThisAddIn.PEPEngine.blacklist_retrieve(); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1220 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1221 |
catch (COMException ex) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1222 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1223 |
blacklist = new string[0]; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1224 |
Log.Error("SetOptionsState: Error getting blacklist from engine. " + ex.ToString()); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1225 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1226 |
|
839 |