当前位置: 首页>>代码示例>>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;未经允许,请勿转载。