@@ -236,7 +236,7 @@ public Layout Body
236
236
/// <docgen category='SMTP Options' order='16' />.
237
237
[ DefaultValue ( false ) ]
238
238
public bool SkipCertificateValidation { get ; set ; }
239
-
239
+
240
240
/// <summary>
241
241
/// Gets or sets the priority used for sending mails.
242
242
/// </summary>
@@ -352,11 +352,11 @@ private void ProcessSingleMailMessage(IList<AsyncLogEventInfo> events)
352
352
InternalLogger . Debug ( "Sending mail to {0} using {1}:{2} (socket option={3})" , message . To , renderedHost , SmtpPort , secureSocketOptions ) ;
353
353
InternalLogger . Trace ( " Subject: '{0}'" , message . Subject ) ;
354
354
InternalLogger . Trace ( " From: '{0}'" , message . From . ToString ( ) ) ;
355
-
356
- if ( SkipCertificateValidation )
355
+
356
+ if ( SkipCertificateValidation )
357
357
client . ServerCertificateValidationCallback += ( s , cert , chain , sslPolicyErrors ) => true ;
358
358
359
-
359
+
360
360
client . Connect ( renderedHost , SmtpPort , secureSocketOptions ) ;
361
361
InternalLogger . Trace ( " Connecting succesfull" ) ;
362
362
@@ -523,16 +523,9 @@ private MimeMessage CreateMailMessage(LogEventInfo lastEvent, string body)
523
523
if ( Priority != null )
524
524
{
525
525
var renderedPriority = Priority . Render ( lastEvent ) ;
526
- try
527
- {
528
-
529
- msg . Priority = ( MessagePriority ) Enum . Parse ( typeof ( MessagePriority ) , renderedPriority , true ) ;
530
- }
531
- catch
532
- {
533
- InternalLogger . Warn ( "Could not convert '{0}' to MessagePriority, valid values are NonUrgent, Normal and Urgent. Using normal priority as fallback." ) ;
534
- msg . Priority = MessagePriority . Normal ;
535
- }
526
+ MessagePriority messagePriority ;
527
+ messagePriority = ParseMessagePriority ( renderedPriority ) ;
528
+ msg . Priority = messagePriority ;
536
529
}
537
530
538
531
TextPart CreateBodyPart ( )
@@ -554,6 +547,38 @@ TextPart CreateBodyPart()
554
547
return msg ;
555
548
}
556
549
550
+ public static MessagePriority ParseMessagePriority ( string priority )
551
+ {
552
+ if ( string . IsNullOrWhiteSpace ( priority ) )
553
+ {
554
+ return MessagePriority . Normal ;
555
+ }
556
+
557
+ priority = priority . Trim ( ) ;
558
+ if ( priority . Equals ( "High" , StringComparison . OrdinalIgnoreCase ) )
559
+ {
560
+ return MessagePriority . Urgent ;
561
+ }
562
+ if ( priority . Equals ( "Low" , StringComparison . OrdinalIgnoreCase ) )
563
+ {
564
+ return MessagePriority . NonUrgent ;
565
+ }
566
+ MessagePriority messagePriority ;
567
+ try
568
+ {
569
+ messagePriority = ( MessagePriority ) Enum . Parse ( typeof ( MessagePriority ) , priority , true ) ;
570
+ }
571
+ catch
572
+ {
573
+ InternalLogger . Warn ( "Could not convert '{0}' to MessagePriority, valid values are NonUrgent, Normal and Urgent. " +
574
+ "Also High and Low could be used as alternatives to Urgent and NonUrgent. " +
575
+ "Using normal priority as fallback." ) ;
576
+ messagePriority = MessagePriority . Normal ;
577
+ }
578
+
579
+ return messagePriority ;
580
+ }
581
+
557
582
/// <summary>
558
583
/// Render <paramref name="layout"/> and add the addresses to <paramref name="mailAddressCollection"/>
559
584
/// </summary>
0 commit comments