public void TestAttachmentSort()
        {
            // test MailMessage(string, string) constructor
                MailMessage msg		= new MailMessage("*****@*****.**", "*****@*****.**");

                // test MailMessage(EamilAddress, EmailAddress) constructor
                EmailAddress from 	= new EmailAddress("*****@*****.**", "Fake Sender");
                EmailAddress to		= new EmailAddress("*****@*****.**", "Fake Recipient");

                Attachment att = new Attachment(@"..\lib\test attachments\test.htm");
                msg.AddAttachment(att);

                Attachment att2 = new Attachment(@"..\lib\test attachments\test.gar");
                msg.AddAttachment(att2);

                Attachment att3 = new Attachment(@"..\lib\test attachments\test.zip");
                msg.AddAttachment(att3);

                Attachment att4 = new Attachment(@"..\lib\test attachments\test.longextension");
                msg.AddAttachment(att4);

                ArrayList attachments = msg.Attachments;
                attachments.Sort();

                Console.WriteLine("\r\n ----- MailMessage.Attachments after sorting -----");
                foreach (Attachment attachment in attachments)
                {
                    Console.WriteLine(attachment.Name);
                }
        }
        protected void Init()
        {
            sender 			= 	"*****@*****.**";
            recipient		= 	"*****@*****.**";
            cc				=	"*****@*****.**";
            senderName 		= 	"FromName";
            recipientName	= 	"ToName";
            ccName			=	"ccName";
            subject			= 	"Mail Message Test\r\n";
            body			=	"Hello from MailMessageTest";
            htmlBody 		= 	"<HTML><HEAD></HEAD><BODY bgColor=\"#00ffff\"><b>Hello Jane. This is the body of the HTML mail message.</b></BODY></HTML>";
            charset			= 	"us-ascii";

            senderEmail 	= new EmailAddress(sender, senderName);
            recipientEmail 	= new EmailAddress(recipient, recipientName);
            ccEmail			= new EmailAddress(cc, ccName);

            msg 			= new MailMessage(senderEmail, recipientEmail);
            msg.AddRecipient("*****@*****.**", AddressType.To);
            msg.AddRecipient("*****@*****.**", AddressType.To);
            msg.Subject 	= subject;
            msg.Body 		= body;
            msg.Charset		= charset;
            msg.Priority 	= MailPriority.High;

            msg.HtmlBody = htmlBody.ToString();
            msg.AddRecipient(ccEmail, AddressType.To);
            msg.AddRecipient(ccEmail, AddressType.Cc);
            msg.AddCustomHeader("X-Something", "Value");
            msg.AddCustomHeader("X-SomethingElse", "Value");
            msg.AddAttachment(@"..\lib\test attachments\test.jpg");
            msg.AddAttachment(@"..\lib\test attachments\test.htm");
            Attachment att = new Attachment(@"..\lib\test attachments\test.zip");
            msg.AddAttachment(att);

            msg.Notification = true;
        }
Ejemplo n.º 3
0
 // end added by mb
 /// <summary>Adds an Attachment to the MailMessage using an Attachment instance</summary>
 /// <param name="attachment">Attachment you want to attach to the MailMessage</param>
 /// <example>
 /// <code>
 /// 	MailMessage msg = new MailMessage("*****@*****.**", "*****@*****.**");
 ///		Attachment att = new Attachment(@"C:\file.jpg");
 ///		msg.AddAttachment(att);
 /// </code>
 /// </example>
 public void AddAttachment(Attachment attachment)
 {
     if (attachment != null)
     {
          attachments.Add(attachment);
      }
 }
Ejemplo n.º 4
0
 public void AddImage(string filepath, string cid)
 {
     if (filepath != null)
     {
         Attachment image = new Attachment(filepath);
         image.contentid=cid;
         images.Add(image);
     }
 }
Ejemplo n.º 5
0
 public void AddAttachment(string filepath, string cid)
 {
     if (filepath != null)
     {
         Attachment attachment = new Attachment(filepath);
         attachment.contentid=cid;
         attachments.Add(attachment);
     }
 }