Produced by Araxis Merge on 10/26/2017 10:44:23 PM Eastern Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | Fri Oct 27 02:44:23 2017 UTC | ||
| 2 | OSCIF_BMS_v2_iter 2_September_2017.zip\BMS_Cand\Source\Sources\BMS.Vista.TestEis\BMS.Utils | SendMail.cs | Wed Oct 18 18:47:02 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 1 | 118 |
| Removed | 0 | 0 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | using Syst em.Net.Mai l; | |||||
| 2 | using Syst em; | |||||
| 3 | using Syst em.Threadi ng; | |||||
| 4 | using Syst em.Compone ntModel; | |||||
| 5 | ||||||
| 6 | namespace BMS.Utils | |||||
| 7 | { | |||||
| 8 | public static cl ass SendMa il | |||||
| 9 | { | |||||
| 10 | pu blic stati c SendMail AsyncResul t Execute( string fro m, string to, string subject, string bod y, string smtpHost, int smtpPo rt, AsyncC allback ca llback) | |||||
| 11 | { | |||||
| 12 | DateTime entryInLo gMethodTim e = DateTi me.UtcNow; | |||||
| 13 | if (Info World.Trac ing.IWTrac e.IsEntryE nabled) | |||||
| 14 | { | |||||
| 15 | Info World.Trac ing.IWTrac e.Entry(Sy stem.Refle ction.Meth odBase.Get CurrentMet hod(), ent ryInLogMet hodTime); | |||||
| 16 | } | |||||
| 17 | try | |||||
| 18 | { | |||||
| 19 | if ( smtpHost ! = null && smtpHost.E quals(Cons tants.NONE , StringCo mparison.I nvariantCu ltureIgnor eCase)) | |||||
| 20 | return nul l; | |||||
| 21 | Mail Message me ssage = ne w MailMess age(); | |||||
| 22 | mess age.From = new MailA ddress(fro m); | |||||
| 23 | mess age.To.Add (to); | |||||
| 24 | mess age.Subjec t = subjec t; | |||||
| 25 | mess age.Body = body; | |||||
| 26 | mess age.IsBody Html = fal se; | |||||
| 27 | ||||||
| 28 | Smtp Client cli ent = new SmtpClient (); | |||||
| 29 | if ( string.IsN ullOrEmpty (smtpHost) ) | |||||
| 30 | { | |||||
| 31 | client.Del iveryMetho d = SmtpDe liveryMeth od.PickupD irectoryFr omIis; | |||||
| 32 | } | |||||
| 33 | else | |||||
| 34 | { | |||||
| 35 | client.Hos t = smtpHo st; | |||||
| 36 | client.Por t = smtpPo rt; | |||||
| 37 | client.Del iveryMetho d = SmtpDe liveryMeth od.Network ; | |||||
| 38 | } | |||||
| 39 | //cl ient.Enabl eSsl = tru e; | |||||
| 40 | ||||||
| 41 | clie nt.UseDefa ultCredent ials = tru e; | |||||
| 42 | //cl ient.UseDe faultCrede ntials = f alse; | |||||
| 43 | ||||||
| 44 | var sendMailAs yncResult = new Send MailAsyncR esult(clie nt, messag e, callbac k); | |||||
| 45 | retu rn sendMai lAsyncResu lt; | |||||
| 46 | } | |||||
| 47 | finally | |||||
| 48 | { | |||||
| 49 | if ( InfoWorld. Tracing.IW Trace.IsEx itEnabled) | |||||
| 50 | { | |||||
| 51 | InfoWorld. Tracing.IW Trace.Exit (System.Re flection.M ethodBase. GetCurrent Method(), DateTime.U tcNow, ent ryInLogMet hodTime); | |||||
| 52 | } | |||||
| 53 | } | |||||
| 54 | } | |||||
| 55 | ||||||
| 56 | pu blic class SendMailA syncResult : IAsyncR esult | |||||
| 57 | { | |||||
| 58 | SmtpClie nt client; | |||||
| 59 | AsyncCal lback call back; | |||||
| 60 | EventWai tHandle as yncWaitHan dle; | |||||
| 61 | MailMess age messag e; | |||||
| 62 | ||||||
| 63 | public b ool Comple tedSynchro nously { g et { retur n false; } } | |||||
| 64 | public W aitHandle AsyncWaitH andle { ge t { return this.asyn cWaitHandl e; } } | |||||
| 65 | public b ool IsComp leted { ge t { return true; } } | |||||
| 66 | public S mtpClient Client { g et { retur n client; } } | |||||
| 67 | ||||||
| 68 | ||||||
| 69 | public S endMailAsy ncResult(S mtpClient client, Ma ilMessage message, A syncCallba ck callbac k/*, objec t state*/) | |||||
| 70 | { | |||||
| 71 | this .client = client; | |||||
| 72 | this .callback = callback ; | |||||
| 73 | this .message = message; | |||||
| 74 | this .asyncWait Handle = n ew EventWa itHandle(f alse, Even tResetMode .AutoReset ); | |||||
| 75 | Thre adPool.Que ueUserWork Item(SendA sync, this ); | |||||
| 76 | } | |||||
| 77 | ||||||
| 78 | void Sen dAsync(obj ect state) | |||||
| 79 | { | |||||
| 80 | Send MailAsyncR esult send er = null; | |||||
| 81 | send er = state as SendMa ilAsyncRes ult; | |||||
| 82 | Exce ption erro r = null; | |||||
| 83 | try | |||||
| 84 | { | |||||
| 85 | if (sender != null) | |||||
| 86 | { | |||||
| 87 | sender .client.Se nd(sender. message); | |||||
| 88 | } | |||||
| 89 | } | |||||
| 90 | catc h (Excepti on e) | |||||
| 91 | { | |||||
| 92 | error = e; | |||||
| 93 | } | |||||
| 94 | fina lly | |||||
| 95 | { | |||||
| 96 | if (sender != null) | |||||
| 97 | { | |||||
| 98 | sender .SendCompl eted(sende r.Client, new AsyncC ompletedEv entArgs(er ror, false , sender)) ; | |||||
| 99 | } | |||||
| 100 | } | |||||
| 101 | } | |||||
| 102 | ||||||
| 103 | void Sen dCompleted (object se nder, Asyn cCompleted EventArgs e) | |||||
| 104 | { | |||||
| 105 | this .asyncWait Handle.Set (); | |||||
| 106 | if ( e.Error != null) | |||||
| 107 | Tracer.Tra ceExceptio n(e.Error) ; | |||||
| 108 | if ( callback ! = null) | |||||
| 109 | callback(t his); | |||||
| 110 | } | |||||
| 111 | ||||||
| 112 | public o bject Asyn cState | |||||
| 113 | { | |||||
| 114 | get { return n ull; } | |||||
| 115 | } | |||||
| 116 | } | |||||
| 117 | } | |||||
| 118 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.