当前位置: 首页>>代码示例>>C#>>正文


C# Email.SendAsync方法代码示例

本文整理汇总了C#中Postal.Email.SendAsync方法的典型用法代码示例。如果您正苦于以下问题:C# Email.SendAsync方法的具体用法?C# Email.SendAsync怎么用?C# Email.SendAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Postal.Email的用法示例。


在下文中一共展示了Email.SendAsync方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Contact

        public async Task<ActionResult> Contact(Models.ContactViewModel contact)
        {
            if (ModelState.IsValid)
            {
                var currentTime = DateTime.UtcNow;
                var elapsedTime = currentTime - contact.TimeSent;
                bool spamFieldFull = !string.IsNullOrEmpty(contact.Check);

                dynamic email = new Email("ContactForm");
                email.From = contact.Email;
                email.CurrentTime = currentTime;
                email.Name = contact.Name;
                email.Title = contact.Title;
                email.Phone = contact.Phone;
                email.Company = contact.Company;
                email.Address = contact.Address;
                email.City = contact.City;
                email.State = contact.State;
                email.Zip = contact.Zip;
                email.Country = contact.Country;
                email.Comments = contact.Comments;
                email.Elapsed = elapsedTime;
                email.SpamFieldFull = spamFieldFull;

                await email.SendAsync();
                return RedirectToAction("ContactSuccess");                                
            }

            return View(contact);
        }
开发者ID:sjpence,项目名称:unitdesign-web,代码行数:30,代码来源:HomeController.cs

示例2: Execute

 public void Execute(ErrorLog errorLog)
 {
     if(string.IsNullOrWhiteSpace(Settings.To)) return;
     dynamic email = new Email("ErrorLog");
     email.From = Settings.From ?? "[email protected]" + errorLog.Host;
     email.To = Settings.To;
     email.Subject = string.Format(Settings.SubjectFormat ?? "Error ({0}): {1}", errorLog.Type, errorLog.Message).Replace(@"\r\n", " ");
     email.Time = errorLog.Time;
     email.Detail = errorLog.Detail;
     email.ServerVariables = errorLog.ServerVariables;
     if(Settings.AttachOriginalError && !string.IsNullOrWhiteSpace(errorLog.Html))
         email.Attach(Attachment.CreateAttachmentFromString(errorLog.Html, "Original ASP.NET error page.html", Encoding.UTF8, "text/html"));
     email.SendAsync();
 }
开发者ID:stevenbey,项目名称:elfar,代码行数:14,代码来源:ErrorLogPlugin.cs

示例3: Send

        public ActionResult Send(string @from, string to, string subject, string message, HttpPostedFileBase file)
        {
            //Regular sending
              //  Helpers.Email.SendEmail(@from,to, "http://localhost:56224/Emails/SendToFriend/SendToFriend.aspx");

            //System.Net.Mail.Attachment attachment;
            //attachment = new System.Net.Mail.Attachment("your attachment file");
            //email.Attachments.Add(attachment);

            // This will look for a view in "~/Views/Emails/Example.cshtml".
            dynamic email = new Email("SendtoFriend/Multipart");
            // Assign any view data to pass to the view.
            // It's dynamic, so you can put whatever you want here.
            email.To = to;
            email.From = @from;
            email.Title = "Custom Title";
            email.Subject = subject;
            email.Message = message;
            email.Date = DateTime.UtcNow;
            ViewBag.Poster = "[email protected]";

            if (file != null)
            {
                email.Attach(new Attachment(file.InputStream, file.FileName));
            }

            // Send the email via a default Postal.EmailService object.
            // This will use the web.config smtp settings.
            try
            {
                email.SendAsync();

            }
            catch (Exception)
            {
                //Write To Database Error
                //Output Message
                Response.Write("Fail");
                throw;
            }

            return RedirectToAction("Sent");
        }
开发者ID:haithemaraissia,项目名称:RentalMVCClean,代码行数:43,代码来源:EmailTestController.cs


注:本文中的Postal.Email.SendAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。