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


C# MailMessage.Save方法代码示例

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


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

示例1: btnMail_Click

 private void btnMail_Click(object sender, EventArgs e)
 {
     CreatePDF();
     MailAddress from = null;
     MailAddress to = null;
     if (!string.IsNullOrEmpty(tblRazonSocial.Rows[0]["CorreoRAZ"].ToString()))
     {
         from = new MailAddress(tblRazonSocial.Rows[0]["CorreoRAZ"].ToString());
     }
     else
     {
         MessageBox.Show("Debe ingresar una dirección de correo en los datos de la empresa", "TREND", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     if (!string.IsNullOrEmpty(tblCliente.Rows[0]["CorreoCLI"].ToString()))
     {
         to = new MailAddress(tblCliente.Rows[0]["CorreoCLI"].ToString());
     }
     else
     {
         to = new MailAddress("[email protected]");
     }
     var mailMessage = new MailMessage(from, to);
     mailMessage.Subject = "Your subject here";
     mailMessage.IsBodyHtml = true;
     //    mailMessage.Body = "<span style='font-size: 12pt; color: red;'>My HTML formatted body</span>";
     mailMessage.Attachments.Add(new Attachment(@"c:\windows\temp\output.pdf"));
     var filename = @"C:\Windows\Temp\message.eml";
     //save the MailMessage to the filesystem
     mailMessage.Save(filename); // utilizo el metodo save de la clase MailUtility en Utilitarios.cs
     //Open the file with the default associated application registered on the local machine
     Process.Start(filename);
 }
开发者ID:BenjaOtero,项目名称:trend-pos-factura,代码行数:32,代码来源:rptFactura.cs

示例2: SaveHtml

        public void SaveHtml()
        {
            MailMessage testMail = new MailMessage();
            testMail.To.Add(new MailAddress("[email protected]"));
            testMail.From = new MailAddress("[email protected]");
            testMail.Subject = "I am subject";
            testMail.Body = "<head>Jason Lee</head>";
            testMail.IsBodyHtml = true;

            testMail.Save(@"c:\Temp\html.eml");
        }
开发者ID:JasonSoft,项目名称:JasonSoft,代码行数:11,代码来源:MailMessageTest.cs

示例3: Dundee

        public void Dundee()
        {
            MailMessage testMail = new MailMessage();
            testMail.To.Add(new MailAddress("[email protected]"));
            testMail.From = new MailAddress("[email protected]");
            testMail.Subject = "I am subject";

            String htmlBody = "郵件";
            AlternateView htmlView = AlternateView.CreateAlternateViewFromString(htmlBody, null, MediaTypeNames.Text.Html);
            htmlView.TransferEncoding = System.Net.Mime.TransferEncoding.SevenBit;

            testMail.AlternateViews.Add(htmlView);
            testMail.Save(@"c:\Temp\jason.eml");
        }
开发者ID:JasonSoft,项目名称:JasonSoft,代码行数:14,代码来源:MailMessageTest.cs

示例4: FileToEmailClientViaMailMessage

        public void FileToEmailClientViaMailMessage()
        {
            string testDataFilePath = @"..\..\Data\test.txt";

            //string mailAddress = WindowsIdentity.GetCurrent().Name;
            string mailAddress = UserPrincipal.Current.EmailAddress;
            var mailMessage = new MailMessage();
            mailMessage.From = new MailAddress(mailAddress);
            mailMessage.Subject = String.Format("File {0} attached", Path.GetFileName(testDataFilePath));
            mailMessage.IsBodyHtml = false;
            //mailMessage.Body = "<span style='font-size: 12pt; color: red;'>My HTML formatted body</span>";
            mailMessage.Attachments.Add(new Attachment(testDataFilePath));

            var filename = Path.Combine(Path.GetTempPath(), "mymessage.eml");
            mailMessage.Save(filename);
            Process.Start(filename);
        }
开发者ID:constructor-igor,项目名称:TechSugar,代码行数:17,代码来源:ToMethodsTests.cs

示例5: SaveHtmlWithImage

        public void SaveHtmlWithImage()
        {
            MailMessage testMail = new MailMessage();
            testMail.To.Add(new MailAddress("[email protected]"));
            testMail.From = new MailAddress("[email protected]");
            testMail.Subject = "I am subject";

            String htmlBody = "<img src=\"cid:uniqueId\" />";
            AlternateView htmlView = AlternateView.CreateAlternateViewFromString(htmlBody, null, MediaTypeNames.Text.Html);
            htmlView.TransferEncoding = System.Net.Mime.TransferEncoding.SevenBit;

            LinkedResource image = new LinkedResource(@"c:\temp\Ascent.jpg");
            image.ContentId = "uniqueId";
            htmlView.LinkedResources.Add(image);

            testMail.AlternateViews.Add(htmlView);
            testMail.Save(@"c:\Temp\testemail.eml");
        }
开发者ID:JasonSoft,项目名称:JasonSoft,代码行数:18,代码来源:MailMessageTest.cs

示例6: SendAttachment

        public static void SendAttachment(string from, string subject, string body, string attachmentPath)
        {
            using (var mailMessage = new MailMessage())
            {
                mailMessage.From = new MailAddress(from);
                mailMessage.Subject = subject;
                mailMessage.IsBodyHtml = true;
                mailMessage.Body = Path.GetFileName(attachmentPath) ?? subject;

                mailMessage.Attachments.Add(new Attachment(attachmentPath));

                var filename = $"{Path.GetFileName(attachmentPath)}.eml";

                //save the MailMessage to the filesystem
                mailMessage.Save(filename);

                //Open the file with the default associated application registered on the local machine
                Process.Start(filename);
            }
        }
开发者ID:codekaizen,项目名称:swifttailer,代码行数:20,代码来源:EmailTasks.cs

示例7: button2_Click

        private void button2_Click(object sender, EventArgs e)
        {
            MailAddress from = new MailAddress("[email protected]");
            MailAddress to = new MailAddress("[email protected]");

            var mailMessage = new MailMessage(from, to);
              //  mailMessage.From = new MailAddress("[email protected]");
            mailMessage.Subject = "Your subject here";
            mailMessage.IsBodyHtml = true;
            mailMessage.Body = "<span style='font-size: 12pt; color: red;'>My HTML formatted body</span>";

            mailMessage.Attachments.Add(new Attachment(@"C:\enviado.xml"));

            var filename = @"C:\Windows\Temp\mymessage.eml";

            //save the MailMessage to the filesystem
            mailMessage.Save(filename);

            //Open the file with the default associated application registered on the local machine
            Process.Start(filename);
        }
开发者ID:BenjaOtero,项目名称:trend-pos-factura,代码行数:21,代码来源:frmPruebas.cs

示例8: SavePlain

        public void SavePlain()
        {
            MailMessage testMail = new MailMessage();
            testMail.To.Add(new MailAddress("[email protected]"));
            testMail.From = new MailAddress("[email protected]");
            testMail.Subject = "I am subject";
            testMail.Body = "Jason Lee";

            testMail.Attachments.Add(new Attachment(@"c:\temp\slide.jpg", MediaTypeNames.Image.Jpeg));
            testMail.Save(@"c:\Temp\plain.eml");
        }
开发者ID:JasonSoft,项目名称:JasonSoft,代码行数:11,代码来源:MailMessageTest.cs

示例9: Send_Email

        private void Send_Email(object sender, RoutedEventArgs e)
        {
            var message = new MailMessage();
            message.From = new MailAddress("[email protected]");
            message.BodyEncoding = System.Text.Encoding.UTF8;
            message.HeadersEncoding = System.Text.Encoding.UTF8;

            PhotosListBox.SelectedItems.Cast<ManagedImage>().ToList().ForEach(
                item => message.Attachments.Add(new Attachment(item.ImageSource))
            );

            // get temporary files
            var filename = String.Format("{0}.{1}", PathUtility.GetTempFileName(), "eml");
            var filenamemod = String.Format("{0}.{1}", PathUtility.GetTempFileName(), "eml");

            //save the MailMessage to the filesystem
            message.Save(filename);

            Regex replacer = new Regex("[email protected]");
            using (TextWriter writer = new StreamWriter(filenamemod))
            {
                using (StreamReader reader = new StreamReader(filename))
                {
                    while (!reader.EndOfStream)
                    {
                        string line = reader.ReadLine();
                        writer.WriteLine(replacer.Replace(line, ""));
                    }
                }
                writer.Flush();
            }

            //Open the file with the default associated application registered on the local machine
            Process.Start(filenamemod);

            // remove temporary file
            File.Delete(filename);
        }
开发者ID:rbobot,项目名称:rbpicman,代码行数:38,代码来源:MainWindow.xaml.cs


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