Thursday, 15 July 2010

c# - SMTP.SendAsync not working correctly -


I am trying to get acquainted with smtp.SendAsync and for some reason I can not find the mailcas to send the ASIN I am here.

Here I have tried.

  // smtp.SendAsync (mm, blank); Error was attempted, operation of ASC was a complete // Task. Before ((=) => smtp.SendAsync (mm, tap)); No error and no email // SMTP S & MALSync (MM)); Error, async operation was attempted, which was completed to each other / Task.Run ((=) => smtp.SendMailAsync (mm)); No error and no email //smtp.Send(mm); Only one works, but it is delayed and that is what I am trying to get away from far away.   

My code:

  Public static zero email (Elevation height, string to email, string to email) {using (bitmap print canvas = shop drawing Margher, Merging, Elevation and Door Uplift, Rotate FlipType.Rocket 90 Fleep Non)) {(var ms = new memorystream ()) {printCanvas.Save (MS, System.Drawings.imaging.imageformat.png); Ms.osition = 0; (MailMessage mm = new mailmessage (new maildirector (via email), new maildood (e-mail)) {mm.Subject = "[Project:" + elevation.ProjectName + "]" + "+" Shop Drawing for Height .Name; Mm.Body = "Your store pictures are attached to this email in the context of the project:" + elevation.ProjectName + "-> height:" + Upgrades .names; = Attachment to new attachment (MS, height. Name + ".PNGG", "image / PNG"); (On) mm.Attachments.Add; (SmtpClient smtp = New SmtpClient ()) using {//smtp.SendAsync (mm, tap)); // task.root (() => smtp.SendAsync (mm, empty)); //smtp.SendMailAsync (mm)); // task.ru (() => smtp.SendMailAsync (mm)); // is the only one who works smtp.Send (mm); }; }; }; }; }    

@Lloyd help wrap the whole body function in a ThreadPool.QueueUserWorkItem from.

  public static void Imelsopdraing Anddurseludebl (IElevation elevation, string of email, string toEmail) {ThreadPool.QueueUserWorkItem (t = & gt; {(bitmap printCanvas = shopDrawing.Merger.MergeElevationAndDoor (height, rotate Flip Type) Rotate90FlipNone) {{using new MS MemoryStream (MS)) {printCanvas.Save (MS, System.Drawing.Imaging.ImageFormat.Png); Ms.Position = 0; Using (MailMessage mm = new MailMessage (new MailAddress (fromEmail), a new mail address (toEmail))) {mm. Subject = "[Project:" + elevation.ProjectName + "]" + "+" shop for height Drawing; name; Mm.Body = "Pictures of your store are related to this email in the context of the project:" + elevation.ProjectName + "-> height:" + elevation.Name; (In the new attachment = attachment (MS, elevation.Name + ".png", "image / png")) {mm. Atkmen (on) ts.Add; (Var smtp = new smtpClient ()) using {smtp.Send (mm); }; }}; }; }; }); }    

No comments:

Post a Comment