本文整理汇总了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);
}
示例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();
}
示例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");
}