@@ -411,33 +411,32 @@ private void SendDownloadNotification(RepositoryInfo objRepository)
411411 {
412412 try
413413 {
414- // check to see if we need to send an email notification
415- if ( string . IsNullOrEmpty ( Convert . ToString ( Settings [ "EmailOnDownload" ] ) ) == false )
414+ bool emailOnDownload = false ;
415+ // check to see if we need to send an email notification
416+ if ( bool . TryParse ( Settings [ "EmailOnDownload" ] . ToString ( ) , out emailOnDownload ) == true &&
417+ emailOnDownload == true )
416418 {
417- if ( bool . Parse ( Settings [ "EmailOnDownload" ] . ToString ( ) ) == true )
419+ string _email = Convert . ToString ( Settings [ "EmailOnDownloadAddress" ] ) ;
420+ if ( string . IsNullOrEmpty ( _email ) == false )
418421 {
419- string _email = Convert . ToString ( Settings [ "EmailOnDownloadAddress" ] ) ;
420- if ( string . IsNullOrEmpty ( _email ) == false )
421- {
422- // send an email
423- string _subject = string . Format ( "[{0}] New Download from Your Repository" , PortalSettings . PortalName ) ;
424- System . Text . StringBuilder _body = new System . Text . StringBuilder ( ) ;
425- _body . Append ( string . Format ( "A new download at {0}<br />" , System . DateTime . Now ) ) ;
426- _body . Append ( string . Format ( "by {0} ({1})<br /><br />" , UserInfo . DisplayName , UserInfo . Email ) ) ;
427- _body . Append ( string . Format ( "File {0}<br /><br />" , objRepository . FileName ) ) ;
428- _body . Append ( "------------------------------------------------------------<br />" ) ;
429- _body . Append ( string . Format ( "{0}<br />" , this . Request . UserHostAddress ) ) ;
430- Mail . SendMail (
431- PortalSettings . Email ,
432- _email ,
433- "" , "" ,
434- Services . Mail . MailPriority . Normal ,
435- _subject ,
436- Services . Mail . MailFormat . Html ,
437- System . Text . Encoding . Default ,
438- _body . ToString ( ) ,
439- "" , "" , "" , "" , "" ) ;
440- }
422+ // send an email
423+ string _subject = string . Format ( "[{0}] New Download from Your Repository" , PortalSettings . PortalName ) ;
424+ System . Text . StringBuilder _body = new System . Text . StringBuilder ( ) ;
425+ _body . Append ( string . Format ( "A new download at {0}<br />" , System . DateTime . Now ) ) ;
426+ _body . Append ( string . Format ( "by {0} ({1})<br /><br />" , UserInfo . DisplayName , UserInfo . Email ) ) ;
427+ _body . Append ( string . Format ( "File {0}<br /><br />" , objRepository . FileName ) ) ;
428+ _body . Append ( "------------------------------------------------------------<br />" ) ;
429+ _body . Append ( string . Format ( "{0}<br />" , this . Request . UserHostAddress ) ) ;
430+ Mail . SendMail (
431+ PortalSettings . Email ,
432+ _email ,
433+ "" , "" ,
434+ Services . Mail . MailPriority . Normal ,
435+ _subject ,
436+ Services . Mail . MailFormat . Html ,
437+ System . Text . Encoding . Default ,
438+ _body . ToString ( ) ,
439+ "" , "" , "" , "" , "" ) ;
441440 }
442441 }
443442 }
0 commit comments