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


C# Mail.LinkedResource类代码示例

本文整理汇总了C#中System.Net.Mail.LinkedResource的典型用法代码示例。如果您正苦于以下问题:C# LinkedResource类的具体用法?C# LinkedResource怎么用?C# LinkedResource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


LinkedResource类属于System.Net.Mail命名空间,在下文中一共展示了LinkedResource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateMailContent

			public override MailContent CreateMailContent()
			{
				GraphControl graphControl = CreateControlImpl();
				MailContent  mailContent = new MailContent();
				MemoryStream ms          = new MemoryStream();

				graphControl.ChartInstance.SaveImage(
					ms,
					ChartImageFormat.Png
				);

				ms.Position = 0;

				LinkedResource imgLink = new LinkedResource(ms, "image/png")
				{
					ContentId = "chart1"
				};

				mailContent.Resource = imgLink;

				mailContent.Message = string.Format(
					@"Graph image:<br> <img src=""cid:chart1"" width=""{0}"" height=""{1}"" > ",
					Preprocessor.GraphicsInfo.Size.Width,
					Preprocessor.GraphicsInfo.Size.Height
				);

				return mailContent;
			}
开发者ID:saycale,项目名称:MSSQLServerAuditor,代码行数:28,代码来源:GraphPreprocessor.cs

示例2: SendMessage

        public override void SendMessage(HtmlMailMessage message)
        {
            if (message.To.Count > 0)
            {
                SmtpClient client = new SmtpClient();

                AlternateView avHtml = AlternateView.CreateAlternateViewFromString(
                    message.Body, null, System.Net.Mime.MediaTypeNames.Text.Html);

                string textBody = "You must use an e-mail client that supports HTML messages";

                // Create an alternate view for unsupported clients
                AlternateView avText = AlternateView.CreateAlternateViewFromString(
                    textBody, null, System.Net.Mime.MediaTypeNames.Text.Plain);

                foreach (KeyValuePair<string, Stream> item in message.LinkedResources)
                {
                    LinkedResource linkedresource = new LinkedResource(
                        item.Value, System.Net.Mime.MediaTypeNames.Image.Jpeg);
                    linkedresource.ContentId = item.Key;
                    avHtml.LinkedResources.Add(linkedresource);
                }

                message.AlternateViews.Add(avHtml);
                message.AlternateViews.Add(avText);

                client.Send(message);
            }
        }
开发者ID:kohku,项目名称:codefactory,代码行数:29,代码来源:SmtpPostOfficeProvider.cs

示例3: AddHtmlView

 public static MailMessage AddHtmlView(this MailMessage mail, string htmlBody, List<string> resources, IResourceResolver resourceResolver)
 {
     if (mail != null && htmlBody.Clear() != null && resources != null && resources.Any())
     {
         if (resourceResolver == null)
         {
             throw new Exception("ResourceResolver not set");
         }
         AlternateView av = AlternateView.CreateAlternateViewFromString(htmlBody, null, MediaTypeNames.Text.Html);
         resources.ForEach(r =>
         {
             HtmlResource hr = resourceResolver.GetHtmlResource(r);
             if (hr != null)
             {
                 MemoryStream ms = new MemoryStream(hr.Content);
                 LinkedResource lr;
                 if (hr.MediaType.Clear() != null)
                 {
                     lr = new LinkedResource(ms, hr.MediaType.Clear());
                 }
                 else
                 {
                     lr = new LinkedResource(ms);
                 }
                 lr.ContentId = hr.ContentId;
                 av.LinkedResources.Add(lr);
             }
             mail.AlternateViews.Add(av);
         });
     }
     return mail;
 }
开发者ID:BikS2013,项目名称:bUtility,代码行数:32,代码来源:ExtensionsLocal.cs

示例4: Main

        static void Main(string[] args)
        {
            MailMessage m = new MailMessage("[email protected]", "[email protected]", "Blah blah blah", "Blah blah body.");
            MailMessage n = new MailMessage(new MailAddress("[email protected]", "Lance Tucker"),
                new MailAddress("[email protected]", "Ben Miller"));

            // Bored now because I've done all this before.

            m.Attachments.Add(new Attachment(@"C:\windows\win.ini"));

            Stream sr = new FileStream(@"C:\Attachment.txt", FileMode.Open, FileAccess.Read);
            m.Attachments.Add(new Attachment(sr, "myfile.txt", MediaTypeNames.Application.Octet));

            string htmlBody = "<html><body><h1>MyMessage</h1|><br>This is an HTML message.<img src=\"cid:Pic1\"></body></html>";
            //m.IsBodyHtml = true;

            AlternateView avHtml = AlternateView.CreateAlternateViewFromString(htmlBody, null, MediaTypeNames.Text.Html);

            LinkedResource pic1 = new LinkedResource("pic.jpg", MediaTypeNames.Image.Jpeg);
            pic1.ContentId = "Pic1";
            avHtml.LinkedResources.Add(pic1);

            string textBody = "You must use an e-mail client that supports HTML messages";
            AlternateView avText = AlternateView.CreateAlternateViewFromString(textBody, null, MediaTypeNames.Text.Plain);

            m.AlternateViews.Add(avHtml);
            m.AlternateViews.Add(avText);

            SmtpClient client = new SmtpClient("smtp.contoso.com");
            client.Send(m);


        }
开发者ID:oblivious,项目名称:Oblivious,代码行数:33,代码来源:Program.cs

示例5: SendEmail

        private static void SendEmail(NotificationData notify, string body)
        {
            MailMessage mailMsg = new MailMessage();
            mailMsg.From = new MailAddress("[email protected]", "Kellogg's Keep Safe Module");
            // TEMPORARY USE ONLY!!!
            //mailMsg.Bcc.Add(new MailAddress("[email protected]", "Melissa Snow"));
            // TEMPORARY USE ONLY!!!

            mailMsg.Subject = "Kellogg's Keep Safe Module - Assignment received";
            //MailAddress mailTo = new MailAddress(address, name);
            //MailAddress mailTo = new MailAddress("[email protected]", "Melissa Snow");
            MailAddress mailTo = new MailAddress("[email protected]", "Dave Arbuckle");
            mailMsg.To.Add(mailTo);

            AlternateView htmlView = null;
            htmlView = AlternateView.CreateAlternateViewFromString(body);
            LinkedResource ksImage = new LinkedResource(Assembly.GetExecutingAssembly().GetManifestResourceStream("AssignmentNotificationEmail.Images.KeepSafe-logo-v6-sml.gif"));
            ksImage.ContentId = "keepsafe";
            htmlView.LinkedResources.Add(ksImage);
            ksImage = new LinkedResource(Assembly.GetExecutingAssembly().GetManifestResourceStream("AssignmentNotificationEmail.Images.University.png"));
            ksImage.ContentId = "training";
            htmlView.LinkedResources.Add(ksImage);

            htmlView.ContentType = new ContentType("text/html");
            mailMsg.AlternateViews.Add(htmlView);

            using (SmtpClient smtp = new SmtpClient("192.168.1.12"))
            {
                Console.WriteLine("Mail to " + mailMsg.To[0].Address);
                smtp.Send(mailMsg);
                LogTheSentEmail(notify.NotificationID);
                System.Threading.Thread.Sleep(250);
            }
        }
开发者ID:zeldafreak,项目名称:Area51,代码行数:34,代码来源:Program.cs

示例6: SendEmail

        public EmailSendingResult SendEmail(EmailArguments emailArguments)
        {
            var sendResult = new EmailSendingResult();
            sendResult.EmailSendingFailureMessage = string.Empty;
            try
            {
                var mailMessage = new MailMessage(emailArguments.From, emailArguments.To);
                mailMessage.Subject = emailArguments.Subject;
                mailMessage.Body = emailArguments.Message;
                mailMessage.IsBodyHtml = emailArguments.Html;
                var client = new SmtpClient(emailArguments.SmtpServer);

                if (emailArguments.EmbeddedResources != null && emailArguments.EmbeddedResources.Count > 0)
                {
                    AlternateView avHtml = AlternateView.CreateAlternateViewFromString(emailArguments.Message, Encoding.UTF8, MediaTypeNames.Text.Html);
                    foreach (EmbeddedEmailResource resource in emailArguments.EmbeddedResources)
                    {
                        LinkedResource linkedResource = new LinkedResource(resource.ResourceStream, resource.ResourceType.ToSystemNetResourceType());
                        linkedResource.ContentId = resource.EmbeddedResourceContentId;
                        avHtml.LinkedResources.Add(linkedResource);
                    }
                    mailMessage.AlternateViews.Add(avHtml);
                }

                client.Send(mailMessage);
                sendResult.EmailSentSuccessfully = true;
            }
            catch (Exception ex)
            {
                sendResult.EmailSendingFailureMessage = ex.Message;
            }

            return sendResult;
        }
开发者ID:richardkundl,项目名称:SampleDI-IoC,代码行数:34,代码来源:EmailService.cs

示例7: Main

        static void Main()
        {

            string filePath = @"..\..\Images\publicdiscussionbanner.jpg";
            //string emailBody = "<html><body><h1>Picture</h1><br><p>This is some picture!</p><img src=\"publicdiscussionbanner.jpg\"></body></html>";
            string emailBody = @"<html>
                                <body>
                                <br>"
                                + "<img src=\"publicdiscussionbanner.jpg\">" +
                                @"<h1>Oбществено обсъждане</h1>
                                <p>Проектът се осъществява с финансовата подкрепа на Оперативна програма “Административен капацитет”, съфинансирана от Европейския съюз чрез Европейския социален фонд.!</p>
                                <div>
	                                <p>
	                                Уважаеми господин Манчев,
	                                Това е тестови имейл, чиято цел е да ви накара да цъкнете на следния линк 
                                    <br>
	                                <a href='www.dir.bg'>Цък!</a>
	                                Благодарим за вниманието!
	                                </p>
                                </div>
                                <footer>
	                                СМ Консулта 2015
                                </footer>
                                </body>
                                </html>";


            AlternateView avHtml = AlternateView.CreateAlternateViewFromString
            (emailBody, null, MediaTypeNames.Text.Html);

            LinkedResource inline = new LinkedResource(filePath, MediaTypeNames.Image.Jpeg);
            inline.ContentId = Guid.NewGuid().ToString();
            avHtml.LinkedResources.Add(inline);

            MailMessage mail = new MailMessage("[email protected]", "[email protected]");
            mail.AlternateViews.Add(avHtml);
            mail.IsBodyHtml = true;
            mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnSuccess;
            mail.Body = String.Format(
                "<h3>Client: " + inline.ContentStream + " Has Sent You A Screenshot</h3>" +
                @"<img src=""cid:{0}"" />", inline.ContentId);

            Attachment att = new Attachment(filePath);
            att.ContentDisposition.Inline = true;
            
            mail.Attachments.Add(att);


            using (SmtpClient client = new SmtpClient("10.10.10.18"))
            {
                //client.EnableSsl = true;
                client.UseDefaultCredentials = false;
                client.Credentials = new NetworkCredential("[email protected]", "smcsupport12");
                client.DeliveryMethod = SmtpDeliveryMethod.Network;
                

                client.Send(mail);
            }
        }
开发者ID:borisov90,项目名称:Projects,代码行数:59,代码来源:Program.cs

示例8: SendNotification

 public void SendNotification(string[] addresses, string title, string message, LinkedResource linkedResource)
 {
     this.Addresses = addresses;
     this.Title = title;
     this.Message = message;
     this.SendNotificationInvoked = true;
     this.LinkedResource = LinkedResource;
 }
开发者ID:ShuHuiC,项目名称:BlobShare,代码行数:8,代码来源:MockNotificationService.cs

示例9: sendMail

 public string sendMail(string userdisplayname, string to, string from, string subject, string msg, string path)
 {
     string str = "";
     SmtpClient client = new SmtpClient
     {
         Credentials = new NetworkCredential(username, passwd),
         Port = port,
         Host = hostname,
         EnableSsl = true,
         DeliveryMethod = SmtpDeliveryMethod.Network,
         Timeout = 20000
     };
     this.mail = new MailMessage();
     string[] strArray = to.Split(new char[] { ',' });
     try
     {
         this.mail.From = new MailAddress(from, userdisplayname, Encoding.UTF8);
         for (byte i = 0; i < strArray.Length; i = (byte)(i + 1))
         {
             this.mail.To.Add(strArray[i]);
         }
         this.mail.Priority = MailPriority.High;
         this.mail.Subject = subject;
         this.mail.Body = msg;
         if (path != "")
         {
             LinkedResource item = new LinkedResource(path)
             {
                 ContentId = "Logo"
             };
             AlternateView view = AlternateView.CreateAlternateViewFromString("<html><body><table border=2><tr width=100%><td><img src=cid:Logo alt=companyname /></td><td>FROM BLUEFROST</td></tr></table><hr/></body></html>" + msg, null, "text/html");
             view.LinkedResources.Add(item);
             this.mail.AlternateViews.Add(view);
             this.mail.IsBodyHtml = true;
             this.mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
             this.mail.ReplyTo = new MailAddress(to);
             client.Send(this.mail);
             return str;
         }
         if (path == "")
         {
             this.mail.IsBodyHtml = true;
             this.mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
             this.mail.ReplyTo = new MailAddress(to);
             client.Send(this.mail);
             str = "good";
         }
     }
     catch (Exception exception)
     {
         if (exception.ToString() == "The operation has timed out")
         {
             client.Send(this.mail);
             str = "bad";
         }
     }
     return str;
 }
开发者ID:ozotony,项目名称:ipocldng,代码行数:58,代码来源:Email.cs

示例10: Init

 private void Init(XmlDocument xmlTemplate)
 {
     XmlElement documentElement = xmlTemplate.DocumentElement;
     base.subject = xmlTemplate.SelectSingleNode("/email-template/subject").InnerText.Trim();
     base.from = xmlTemplate.SelectSingleNode("/email-template/addresses/entry[@name='From']").Attributes["value"].InnerText;
     base.to = xmlTemplate.SelectSingleNode("/email-template/addresses/entry[@name='To']").Attributes["value"].InnerText;
     XmlNode node = xmlTemplate.SelectSingleNode("/email-template/addresses/entry[@name='Cc']");
     if (node != null)
     {
         base.cc = node.Attributes["value"].InnerText;
     }
     XmlNode node2 = xmlTemplate.SelectSingleNode("/email-template/addresses/entry[@name='Bcc']");
     if (node2 != null)
     {
         base.bcc = node2.Attributes["value"].InnerText;
     }
     base.body = xmlTemplate.SelectSingleNode("/email-template/body").InnerText.Trim();
     base.bodyContentType = xmlTemplate.SelectSingleNode("/email-template/body/@format").InnerText;
     string innerText = xmlTemplate.SelectSingleNode("/email-template/body/@encoding").InnerText;
     try
     {
         base.bodyEncoding = Encoding.GetEncoding(innerText);
     }
     catch
     {
         base.bodyEncoding = Encoding.GetEncoding("iso-8859-1");
     }
     XmlNodeList list = xmlTemplate.SelectNodes("/email-template/embeddedResources/resource");
     if ((list != null) && (list.Count > 0))
     {
         string directoryName = Path.GetDirectoryName(this.xmlTemplateFile);
         foreach (XmlNode node3 in list)
         {
             try
             {
                 string str3 = node3.Attributes["name"].Value;
                 string str4 = node3.Attributes["path"].Value;
                 string str5 = "application/octet-stream";
                 if (node3.Attributes["content-type"] != null)
                 {
                     str5 = node3.Attributes["content-type"].Value;
                 }
                 if (!(string.IsNullOrEmpty(str3) || string.IsNullOrEmpty(str4)))
                 {
                     LinkedResource item = new LinkedResource(Path.Combine(directoryName, str4));
                     item.ContentId = str3;
                     item.ContentType.Name = str3;
                     item.ContentType.MediaType = str5;
                     base.LinkedResources.Add(item);
                 }
             }
             catch (Exception exception)
             {
                 throw new InvalidEmailTemplateException("<embeddedResources> node is not in correct format.\r\n                            Example:\r\n                                <embeddedResources>\r\n                                    <resource name=\"logo\" path=\"images\\logo.gif\" content-type=\"image/jpeg\"/>\r\n                                </embeddedResources>", exception);
             }
         }
     }
 }
开发者ID:vinasourcetutran,项目名称:searchengine,代码行数:58,代码来源:XmlEmailTemplate.cs

示例11: SerializableLinkedResource

		private SerializableLinkedResource(LinkedResource resource) {
			ContentLink = resource.ContentLink;
			ContentId = resource.ContentId;
			ContentStream = new MemoryStream();
			resource.ContentStream.CopyTo(ContentStream);
			resource.ContentStream.Position = 0;
			ContentType = resource.ContentType;
			TransferEncoding = resource.TransferEncoding;
		}
开发者ID:sadiqna,项目名称:TicketDesk,代码行数:9,代码来源:SerializableLinkedResource.cs

示例12: CreateEmbeddedImageAsync

 private async Task<LinkedResource> CreateEmbeddedImageAsync(string path, string CID)
 {
     return await Task.Run(() => {
         LinkedResource image = new LinkedResource(path);
         image.ContentId = CID;
         image.ContentType = new ContentType("image/jpg");
         return image;
     });
 }
开发者ID:pandazzurro,项目名称:uPlayAgain,代码行数:9,代码来源:EmailService.cs

示例13: SendNotification

        public void SendNotification(string[] addresses, string title, string htmlMessage, LinkedResource linkedResource, IDictionary<string, string> messageParameters)
        {
            foreach (var messageParameter in messageParameters)
            {
                htmlMessage = htmlMessage.Replace(messageParameter.Key, messageParameter.Value);
            }

            this.SendNotification(addresses, title, htmlMessage, linkedResource, false);
        }
开发者ID:ShuHuiC,项目名称:BlobShare,代码行数:9,代码来源:SmtpNotificationService.cs

示例14: SendReport

    public static void SendReport()
    {
      SI.Controls.LookFeel.SetupJamesPurple();

      MailMessage msg = new MailMessage("[email protected]", "[email protected]",
        "invoice spreads", "body");
      msg.To.Clear();
      msg.CC.Add("[email protected]");
      //msg.To.Add("[email protected]");
      //msg.To.Add("[email protected]");
      //msg.To.Add("[email protected]");

      var con = InvoiceSpreadGenerator.GetInvoiceSpreadsAsConstruct();

      var path = string.Format(@"c:\temp\invoiceSpreads_{0}.csv", DateTime.Today.ToString("yyyyMMdd"));
      con.WriteToCSV(path);

      var bodyBuilder = new StringBuilder();
      var resourceDict = new Dictionary<string, string>();


      addChart(bodyBuilder, new InvoiceSpreadStructures.TU_1_Libor(), resourceDict);
      addChart(bodyBuilder, new InvoiceSpreadStructures.TU_2_Libor(), resourceDict);
      addChart(bodyBuilder, new InvoiceSpreadStructures.TY_1_Libor(), resourceDict);
      addChart(bodyBuilder, new InvoiceSpreadStructures.TY_2_Libor(), resourceDict);
      addChart(bodyBuilder, new InvoiceSpreadStructures.FV_1_Libor(), resourceDict);
      addChart(bodyBuilder, new InvoiceSpreadStructures.FV_2_Libor(), resourceDict);
      addChart(bodyBuilder, new InvoiceSpreadStructures.FVTY_1_Libor(), resourceDict);
      addChart(bodyBuilder, new InvoiceSpreadStructures.FVTY_2_Libor(), resourceDict);
      addChart(bodyBuilder, new InvoiceSpreadStructures.TUFV_1_Libor(), resourceDict);
      addChart(bodyBuilder, new InvoiceSpreadStructures.TUFV_2_Libor(), resourceDict);


      msg.Body = bodyBuilder.ToString();
      msg.IsBodyHtml = true;

      AlternateView htmlView = AlternateView.CreateAlternateViewFromString(msg.Body, null, "text/html");
      foreach (var k in resourceDict.Keys)
      {
        LinkedResource lr = new LinkedResource(resourceDict[k]) { ContentId = k };
        htmlView.LinkedResources.Add(lr);
      }

      msg.AlternateViews.Add(htmlView);


      msg.Attachments.Add(new Attachment(path));

      try
      {
        Emailer.GetClient().Send(msg);
      }
      catch (Exception ex_)
      {
        Logger.Error("Error sending mail", typeof (InvoiceSpreadReportGenerator), ex_);
      }
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:57,代码来源:InvoiceSpreadReportGenerator.cs

示例15: GetLinkedResource

        internal LinkedResource GetLinkedResource()
        {
            LinkedResource slr = new LinkedResource(_contentStream);
            slr.ContentId = _contentId;
            slr.ContentLink = _contentLink;

            slr.ContentType = _contentType.GetContentType();
            slr.TransferEncoding = _transferEncoding;

            return slr;
        }
开发者ID:johnpipo1712,项目名称:Misuka,代码行数:11,代码来源:LinkedResourceWrapper.cs


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