@@ -82,6 +82,7 @@ internal CheckList GenerateCheckListFromMail<T>(T item, GeneralSetting generalSe
82
82
var attachmentsSettingCsv = new ReadAndWriteCsv ( "AttachmentsSetting.csv" ) ;
83
83
var attachmentsSettingList = attachmentsSettingCsv . GetCsvRecords < AttachmentsSetting > ( attachmentsSettingCsv . LoadCsv < AttachmentsSettingMap > ( ) ) ;
84
84
if ( attachmentsSettingList . Count > 0 ) attachmentsSetting = attachmentsSettingList [ 0 ] ;
85
+ if ( string . IsNullOrEmpty ( attachmentsSetting . TargetAttachmentFileExtensionOfOpen ) ) attachmentsSetting . TargetAttachmentFileExtensionOfOpen = ".pdf,.txt,.csv,.rtf,.htm,.html,.doc,.docx,.xls,.xlm,.xlsm,.xlsx,.ppt,.pptx,.bmp,.gif,.jpg,.jpeg,.png,.fif,.pub,.vsd,.vsdx" ;
85
86
86
87
var recipientsAndAttachmentsNameCsv = new ReadAndWriteCsv ( "RecipientsAndAttachmentsName.csv" ) ;
87
88
var recipientsAndAttachmentsNameList = recipientsAndAttachmentsNameCsv . GetCsvRecords < RecipientsAndAttachmentsName > ( recipientsAndAttachmentsNameCsv . LoadCsv < RecipientsAndAttachmentsNameMap > ( ) )
@@ -102,22 +103,22 @@ internal CheckList GenerateCheckListFromMail<T>(T item, GeneralSetting generalSe
102
103
103
104
#endregion
104
105
105
- var isMailItem = ( typeof ( T ) == typeof ( Outlook . _MailItem ) ) ;
106
+ var isMailItem = ( typeof ( T ) == typeof ( Outlook . MailItem ) ) ;
106
107
107
108
if ( isMailItem )
108
109
{
109
- _checkList . MailType = GetMailBodyFormat ( ( ( Outlook . _MailItem ) item ) . BodyFormat ) ?? Resources . FailedToGetInformation ;
110
- _checkList . MailBody = GetMailBody ( ( ( Outlook . _MailItem ) item ) . BodyFormat , ( ( Outlook . _MailItem ) item ) . Body ?? Resources . FailedToGetInformation ) ;
110
+ _checkList . MailType = GetMailBodyFormat ( ( ( Outlook . MailItem ) item ) . BodyFormat ) ?? Resources . FailedToGetInformation ;
111
+ _checkList . MailBody = GetMailBody ( ( ( Outlook . MailItem ) item ) . BodyFormat , ( ( Outlook . MailItem ) item ) . Body ?? Resources . FailedToGetInformation ) ;
111
112
_checkList . MailBody = AddMessageToBodyPreview ( _checkList . MailBody , autoAddMessageSetting ) ;
112
113
113
- _checkList . MailHtmlBody = ( ( Outlook . _MailItem ) item ) . HTMLBody ?? Resources . FailedToGetInformation ;
114
+ _checkList . MailHtmlBody = ( ( Outlook . MailItem ) item ) . HTMLBody ?? Resources . FailedToGetInformation ;
114
115
}
115
116
else
116
117
{
117
118
_checkList . MailType = Resources . MeetingRequest ;
118
- _checkList . MailBody = string . IsNullOrEmpty ( ( ( Outlook . _MeetingItem ) item ) . Body ) ? Resources . FailedToGetInformation : ( ( Outlook . _MeetingItem ) item ) . Body . Replace ( "\r \n \r \n " , "\r \n " ) ;
119
+ _checkList . MailBody = string . IsNullOrEmpty ( ( ( Outlook . MeetingItem ) item ) . Body ) ? Resources . FailedToGetInformation : ( ( Outlook . MeetingItem ) item ) . Body . Replace ( "\r \n \r \n " , "\r \n " ) ;
119
120
120
- if ( ( ( Outlook . _MeetingItem ) item ) . RTFBody is byte [ ] byteArray )
121
+ if ( ( ( Outlook . MeetingItem ) item ) . RTFBody is byte [ ] byteArray )
121
122
{
122
123
var encoding = new System . Text . ASCIIEncoding ( ) ;
123
124
_checkList . MailHtmlBody = encoding . GetString ( byteArray ) ;
@@ -176,27 +177,27 @@ private CheckList GetSenderAndSenderDomain<T>(in T item, CheckList checkList)
176
177
{
177
178
try
178
179
{
179
- if ( typeof ( T ) == typeof ( Outlook . _MailItem ) && ! string . IsNullOrEmpty ( ( ( Outlook . _MailItem ) item ) . SentOnBehalfOfName ) )
180
+ if ( typeof ( T ) == typeof ( Outlook . MailItem ) && ! string . IsNullOrEmpty ( ( ( Outlook . MailItem ) item ) . SentOnBehalfOfName ) )
180
181
{
181
182
//代理送信の場合。
182
- checkList . Sender = ( ( Outlook . _MailItem ) item ) . Sender ? . Address ?? Resources . FailedToGetInformation ;
183
+ checkList . Sender = ( ( Outlook . MailItem ) item ) . Sender ? . Address ?? Resources . FailedToGetInformation ;
183
184
184
185
if ( IsValidEmailAddress ( checkList . Sender ) )
185
186
{
186
187
//メールアドレスが取得できる場合はそのまま使う。
187
188
checkList . SenderDomain = checkList . Sender . Substring ( checkList . Sender . IndexOf ( "@" , StringComparison . Ordinal ) ) ;
188
- checkList . Sender = $@ "{ checkList . Sender } ([{ ( ( Outlook . _MailItem ) item ) . SentOnBehalfOfName } ] { Resources . SentOnBehalf } )";
189
+ checkList . Sender = $@ "{ checkList . Sender } ([{ ( ( Outlook . MailItem ) item ) . SentOnBehalfOfName } ] { Resources . SentOnBehalf } )";
189
190
}
190
191
else
191
192
{
192
193
//代理送信の場合かつExchangeのCN。
193
- checkList . Sender = $@ "[{ ( ( Outlook . _MailItem ) item ) . SentOnBehalfOfName } ] { Resources . SentOnBehalf } ";
194
+ checkList . Sender = $@ "[{ ( ( Outlook . MailItem ) item ) . SentOnBehalfOfName } ] { Resources . SentOnBehalf } ";
194
195
checkList . SenderDomain = @"------------------" ;
195
196
196
197
Outlook . ExchangeDistributionList exchangeDistributionList = null ;
197
198
Outlook . ExchangeUser exchangeUser = null ;
198
199
199
- var sender = ( ( Outlook . _MailItem ) item ) . Sender ;
200
+ var sender = ( ( Outlook . MailItem ) item ) . Sender ;
200
201
201
202
var isDone = false ;
202
203
var errorCount = 0 ;
@@ -227,14 +228,14 @@ private CheckList GetSenderAndSenderDomain<T>(in T item, CheckList checkList)
227
228
if ( ! ( exchangeUser is null ) )
228
229
{
229
230
//ユーザの代理送信。
230
- checkList . Sender = $@ "{ exchangeUser . PrimarySmtpAddress } ([{ ( ( Outlook . _MailItem ) item ) . SentOnBehalfOfName } ] { Resources . SentOnBehalf } )";
231
+ checkList . Sender = $@ "{ exchangeUser . PrimarySmtpAddress } ([{ ( ( Outlook . MailItem ) item ) . SentOnBehalfOfName } ] { Resources . SentOnBehalf } )";
231
232
checkList . SenderDomain = exchangeUser . PrimarySmtpAddress . Substring ( exchangeUser . PrimarySmtpAddress . IndexOf ( "@" , StringComparison . Ordinal ) ) ;
232
233
}
233
234
234
235
if ( ! ( exchangeDistributionList is null ) )
235
236
{
236
237
//配布リストの代理送信。
237
- checkList . Sender = $@ "{ exchangeDistributionList . PrimarySmtpAddress } ([{ ( ( Outlook . _MailItem ) item ) . SentOnBehalfOfName } ] { Resources . SentOnBehalf } )";
238
+ checkList . Sender = $@ "{ exchangeDistributionList . PrimarySmtpAddress } ([{ ( ( Outlook . MailItem ) item ) . SentOnBehalfOfName } ] { Resources . SentOnBehalf } )";
238
239
checkList . SenderDomain = exchangeDistributionList . PrimarySmtpAddress . Substring ( exchangeDistributionList . PrimarySmtpAddress . IndexOf ( "@" , StringComparison . Ordinal ) ) ;
239
240
}
240
241
}
@@ -1017,11 +1018,11 @@ private CheckList CheckKeywordForSubject(CheckList checkList, IReadOnlyCollectio
1017
1018
1018
1019
var mailItemSender = ( ( dynamic ) item ) . SenderEmailAddress ;
1019
1020
1020
- if ( typeof ( T ) == typeof ( Outlook . _MailItem ) )
1021
+ if ( typeof ( T ) == typeof ( Outlook . MailItem ) )
1021
1022
{
1022
- if ( ! string . IsNullOrEmpty ( ( ( Outlook . _MailItem ) item ) . SentOnBehalfOfName ) && ! string . IsNullOrEmpty ( ( ( Outlook . _MailItem ) item ) . Sender . Address ) )
1023
+ if ( ! string . IsNullOrEmpty ( ( ( Outlook . MailItem ) item ) . SentOnBehalfOfName ) && ! string . IsNullOrEmpty ( ( ( Outlook . MailItem ) item ) . Sender . Address ) )
1023
1024
{
1024
- mailItemSender = ( ( Outlook . _MailItem ) item ) . Sender . Address ;
1025
+ mailItemSender = ( ( Outlook . MailItem ) item ) . Sender . Address ;
1025
1026
}
1026
1027
}
1027
1028
@@ -1118,10 +1119,10 @@ private CheckList CheckKeywordForSubject(CheckList checkList, IReadOnlyCollectio
1118
1119
/// <returns>埋め込みファイル名のList</returns>
1119
1120
private List < string > MakeEmbeddedAttachmentsList < T > ( T item , string mailHtmlBody )
1120
1121
{
1121
- if ( typeof ( T ) == typeof ( Outlook . _MailItem ) )
1122
+ if ( typeof ( T ) == typeof ( Outlook . MailItem ) )
1122
1123
{
1123
1124
//HTML形式の場合のみ、処理対象とする。
1124
- if ( ( ( Outlook . _MailItem ) item ) . BodyFormat != Outlook . OlBodyFormat . olFormatHTML ) return null ;
1125
+ if ( ( ( Outlook . MailItem ) item ) . BodyFormat != Outlook . OlBodyFormat . olFormatHTML ) return null ;
1125
1126
}
1126
1127
1127
1128
var matches = Regex . Matches ( mailHtmlBody , @"cid:.*?@" ) ;
@@ -1158,6 +1159,7 @@ private CheckList GetAttachmentsInformation<T>(in T item, CheckList checkList, b
1158
1159
1159
1160
var tempDirectoryPath = Path . Combine ( Path . GetTempPath ( ) , Guid . NewGuid ( ) . ToString ( "N" ) ) ;
1160
1161
_ = Directory . CreateDirectory ( tempDirectoryPath ) ;
1162
+ checkList . TempFilePath = tempDirectoryPath ;
1161
1163
1162
1164
for ( var i = 0 ; i < ( ( dynamic ) item ) . Attachments . Count ; i ++ )
1163
1165
{
@@ -1207,14 +1209,16 @@ private CheckList GetAttachmentsInformation<T>(in T item, CheckList checkList, b
1207
1209
if ( fileType == ".p7s" || fileType == "p7s" ) continue ;
1208
1210
1209
1211
var isEncrypted = false ;
1210
-
1212
+ var tempFilePath = "" ;
1213
+ var isCanOpen = false ;
1211
1214
try
1212
1215
{
1216
+
1213
1217
if ( ( attachmentsSetting . IsWarningWhenEncryptedZipIsAttached || attachmentsSetting . IsProhibitedWhenEncryptedZipIsAttached ) && fileName != Resources . Unknown )
1214
1218
{
1215
1219
if ( attachmentsSetting . IsEnableAllAttachedFilesAreDetectEncryptedZip || fileType == ".zip" || fileType == "zip" )
1216
1220
{
1217
- var tempFilePath = Path . Combine ( tempDirectoryPath , fileName ) ;
1221
+ tempFilePath = Path . Combine ( tempDirectoryPath , fileName ) ;
1218
1222
( ( dynamic ) item ) . Attachments [ i + 1 ] . SaveAsFile ( tempFilePath ) ;
1219
1223
1220
1224
var zipTools = new ZipTools ( ) ;
@@ -1235,6 +1239,14 @@ private CheckList GetAttachmentsInformation<T>(in T item, CheckList checkList, b
1235
1239
File . Delete ( tempFilePath ) ;
1236
1240
}
1237
1241
}
1242
+
1243
+ if ( attachmentsSetting . IsEnableOpenAttachedFiles && attachmentsSetting . TargetAttachmentFileExtensionOfOpen . ToLower ( ) . Contains ( fileType . ToLower ( ) ) )
1244
+ {
1245
+ //ファイルを開くためにテンポラリディレクトリにコピーして、そのパスを記録
1246
+ tempFilePath = Path . Combine ( tempDirectoryPath , fileName ) ;
1247
+ ( ( dynamic ) item ) . Attachments [ i + 1 ] . SaveAsFile ( tempFilePath ) ;
1248
+ isCanOpen = true ;
1249
+ }
1238
1250
}
1239
1251
catch ( Exception )
1240
1252
{
@@ -1251,7 +1263,11 @@ private CheckList GetAttachmentsInformation<T>(in T item, CheckList checkList, b
1251
1263
IsTooBig = ( ( dynamic ) item ) . Attachments [ i + 1 ] . Size >= 10485760 ,
1252
1264
IsEncrypted = isEncrypted ,
1253
1265
IsChecked = false ,
1254
- IsDangerous = isDangerous
1266
+ IsDangerous = isDangerous ,
1267
+ IsCanOpen = isCanOpen ,
1268
+ IsNotMustOpenBeforeCheck = ! ( attachmentsSetting . IsEnableOpenAttachedFiles && attachmentsSetting . IsMustOpenBeforeCheckTheAttachedFiles && isCanOpen ) ,
1269
+ Open = isCanOpen ? Resources . Open : "---" ,
1270
+ FilePath = tempFilePath
1255
1271
} ) ;
1256
1272
1257
1273
continue ;
@@ -1268,7 +1284,11 @@ private CheckList GetAttachmentsInformation<T>(in T item, CheckList checkList, b
1268
1284
IsTooBig = ( ( dynamic ) item ) . Attachments [ i + 1 ] . Size >= 10485760 ,
1269
1285
IsEncrypted = isEncrypted ,
1270
1286
IsChecked = false ,
1271
- IsDangerous = isDangerous
1287
+ IsDangerous = isDangerous ,
1288
+ IsCanOpen = isCanOpen ,
1289
+ IsNotMustOpenBeforeCheck = ! ( attachmentsSetting . IsEnableOpenAttachedFiles && attachmentsSetting . IsMustOpenBeforeCheckTheAttachedFiles && isCanOpen ) ,
1290
+ Open = isCanOpen ? Resources . Open : "---" ,
1291
+ FilePath = tempFilePath
1272
1292
} ) ;
1273
1293
}
1274
1294
}
0 commit comments