當前位置: 首頁>>代碼示例>>C#>>正文


C# Email.Attach方法代碼示例

本文整理匯總了C#中Postal.Email.Attach方法的典型用法代碼示例。如果您正苦於以下問題:C# Email.Attach方法的具體用法?C# Email.Attach怎麽用?C# Email.Attach使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Postal.Email的用法示例。


在下文中一共展示了Email.Attach方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: SendReportMail

        public static void SendReportMail(List<string> attachmentPaths, ContractUser user)
        {
            dynamic email = new Email("ReportMail");
            email.to = user.Email;
            email.from = applicationEmail;

            foreach(string path in attachmentPaths)
            {
                email.Attach(new Attachment(path));
            }
            email.Send();
        }
開發者ID:R-Carver,項目名稱:Code-fueMoses,代碼行數:12,代碼來源:MailUtility.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: Attachments_are_added_to_MailMessage

        public void Attachments_are_added_to_MailMessage()
        {
            var input = @"
            To: [email protected]
            From: [email protected]
            Subject: Test Subject

            Hello, World!";
            var email = new Email("Test");
            email.Attach(new Attachment(new MemoryStream(), "name"));
            var parser = new EmailParser(Mock.Of<IEmailViewRenderer>());

            var message = parser.Parse(input, email);

            message.Attachments.Count.ShouldEqual(1);
        }
開發者ID:robitar,項目名稱:postal,代碼行數:16,代碼來源:EmailParserTests.cs

示例4: 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

示例5: Send

        public ActionResult Send(string to, string subject, string message, HttpPostedFileBase file)
        {
            // This will look for a view in "~/Views/Emails/Example.cshtml".
            dynamic email = new Email("Example");
            // Assign any view data to pass to the view.
            // It's dynamic, so you can put whatever you want here.
            email.To = to;
            email.Subject = subject;
            email.Message = message;
            email.Date = DateTime.UtcNow;

            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.
            email.Send();

            // In 'real code' you probably want to use the Postal.IEmailService interface
            // to allow for mocking out the sending of email in tests.
            //
            // The controller's constructor would look like this:
            //   public HomeController(IEmailService emailService) {
            //     this.emailService = emailService;
            //   }
            //
            // Then actions can send email using:
            //   emailService.Send(email);

            // Alternatively, you can just ask for the MailMessage to be created.
            // It contains the rendered email body and headers (To, From, etc).
            // You can then send this yourself using any method you like.
            // using (var mailMessage = emailService.CreateMailMessage(email))
            // {
            //     MyEmailGateway.Send(mailMessage);
            // }

            return RedirectToAction("Sent");
        }
開發者ID:tarr11,項目名稱:postal,代碼行數:41,代碼來源:HomeController.cs

示例6: Email

        public JsonResult Email(string email, string path)
        {
            string root = ConfigurationManager.AppSettings["FilesRoot"];
            root = root.Trim().EndsWith(@"\") ? root = root.Substring(0, root.Length - 2) : root;

            var fullpath = string.Format(@"{0}{1}", ConfigurationManager.AppSettings["FilesRoot"], path.Replace("/", "\\"));

            var cookie = Request.Cookies["rephidim"];
            if (cookie == null)
            {
                cookie = new HttpCookie("rephidim");
            }
            cookie["email"] = email;
            cookie.Expires = DateTime.Now.AddMonths(12);
            Response.Cookies.Add(cookie);

            dynamic msg = new Email("FileAttach");
            msg.To = email;
            msg.Path = path;
            msg.Attach(new System.Net.Mail.Attachment(fullpath));
            msg.Send();

            return Json(true);
        }
開發者ID:jslaybaugh,項目名稱:rephidim-web,代碼行數:24,代碼來源:FilesController.cs

示例7: Attach_adds_attachment

 public void Attach_adds_attachment()
 {
     dynamic email = new Email("Test");
     var attachment = new Attachment(new MemoryStream(), "name");
     email.Attach(attachment);
     ((Email)email).Attachments.ShouldContain(attachment);
 }
開發者ID:Choulla-Naresh8264,項目名稱:postal,代碼行數:7,代碼來源:EmailTests.cs


注:本文中的Postal.Email.Attach方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。