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


C# MailAddressCollection类代码示例

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


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

示例1: SendMail

        public static void SendMail(string FromName, string Subject, string Body, MailAddressCollection addresses)
        {
            System.Net.Mail.MailMessage email = new System.Net.Mail.MailMessage();
            for (int i = 0; i < addresses.Count; i++) {
                email.To.Add(addresses[i]);
            }

            email.From = new MailAddress(ConfigurationManager.AppSettings["FromEmail"], FromName);
            email.Subject = Subject;

            email.Body = Body;
            email.IsBodyHtml = true;
            email.Priority = MailPriority.Normal;
            email.BodyEncoding = System.Text.Encoding.UTF8;
            SmtpClient mailClient = new System.Net.Mail.SmtpClient();
            mailClient.Timeout = 400000;
            mailClient.EnableSsl = false;

            mailClient.DeliveryMethod = SmtpDeliveryMethod.Network;

            NetworkCredential basicAuthenticationInfo =
                new NetworkCredential("[email protected]", "147258");
            mailClient.Host = "mail.dbhsoft.com";
            mailClient.Credentials = basicAuthenticationInfo;
            mailClient.Port = 587;

            try {
                mailClient.Send(email);
            } catch (Exception) {
                throw;
            }
        }
开发者ID:anarbek,项目名称:daily-deal,代码行数:32,代码来源:MailSender.cs

示例2: AddMailsToCollection

 /// <summary>
 /// Adds the mails to the address-collection.
 /// </summary>
 /// <param name="collection">The collection.</param>
 /// <param name="addresses">The addresses.</param>
 private void AddMailsToCollection(MailAddressCollection collection, IEnumerable<string> addresses)
 {
     foreach (string address in addresses)
     {
         collection.Add(new MailAddress(address));
     }
 }
开发者ID:Alex9,项目名称:ProjectCoach,代码行数:12,代码来源:EMailSender.cs

示例3: Enviar

 public static void Enviar(MailAddress to, String body, String subject, List<Attachment> attachments)
 {
     MailAddressCollection emails = new MailAddressCollection();
     emails.Add(to);
     MailAddress from = Util.Email.EmailEnvioPadrao;
     Enviar(from, emails, body, subject, attachments);
 }
开发者ID:salez,项目名称:Guirotab,代码行数:7,代码来源:Email.cs

示例4: SendEmail

 public void SendEmail(MailAddress from, MailAddressCollection to, MailAddressCollection cc, MailAddressCollection bcc, string subj, string body)
 {
     MailMessage msg = new MailMessage();
     foreach(MailAddress item in to)
     {
         msg.To.Add(item);
     }
     foreach (MailAddress item in cc)
     {
         msg.CC.Add(item);
     }
     foreach (MailAddress item in bcc)
     {
         msg.Bcc.Add(item);
     }
     msg.From = from;
     msg.Sender = from;
     Log.Info("Preparing message FROM " + from.DisplayName + " at address " + from.Address);
     msg.Subject = subj;
     msg.Body = body;
     Log.Info("Sending email message...");
     try
     {
         tseClient.Send(msg);
     }
     catch (Exception)
     {
         throw;
     }
 }
开发者ID:CodeFork,项目名称:TSEmailer,代码行数:30,代码来源:smtpWrapper.cs

示例5: SendAnEmail

        public void SendAnEmail()
        {
            bool _success = false;
            try
            {
                MailMessage _message = new MailMessage();
                SmtpClient _smptClient = new SmtpClient();

                _message.Subject = _emailSubject;

                _message.Body = _emailBody;

                MailAddress _mailFrom = new MailAddress(_emailFrom,_emailFromFriendlyName);
            
                MailAddressCollection _mailTo = new MailAddressCollection();
                _mailTo.Add(_emailTo);

                _message.From = _mailFrom;
                _message.To.Add(new MailAddress(_emailTo,_emailToFriendlyName));

                System.Net.NetworkCredential _crens = new System.Net.NetworkCredential(
                    _smtpHostUserName,_smtpHostPassword);
                _smptClient.Host = _smtpHost;
                _smptClient.Credentials = _crens;


                _smptClient.Send(_message);
            }
            catch (Exception er)
            {
                string s1 = er.Message;
            }
        }
开发者ID:connecticutortho,项目名称:ct-ortho-repositories4,代码行数:33,代码来源:SendEmail.cs

示例6: Send

        public static void Send(MailAddress from, MailAddress replyTo, MailAddress to, string subject, string body)
        {
            MailAddressCollection toList = new MailAddressCollection();
            toList.Add(to);

            Send(from, replyTo, toList, subject, body);
        }
开发者ID:Qupy,项目名称:Extensions,代码行数:7,代码来源:EmailUtility.cs

示例7: SendAnEmail

        public void SendAnEmail()
        {
            try
            {
                MailMessage _message = new MailMessage();
                SmtpClient _smptClient = new SmtpClient();

                _message.Subject = _emailSubject;

                _message.Body = _emailBody;

                MailAddress _mailFrom = new MailAddress(_emailFrom,_emailFromFriendlyName);
            
                MailAddressCollection _mailTo = new MailAddressCollection();
                _mailTo.Add(_emailTo);

                _message.From = _mailFrom;
                _message.To.Add(new MailAddress(_emailTo,_emailToFriendlyName));

                System.Net.NetworkCredential _crens = new System.Net.NetworkCredential(
                    _smtpHostUserName,_smtpHostPassword);
                _smptClient.Host = _smtpHost;
                _smptClient.Credentials = _crens;


                _smptClient.Send(_message);
            }
            catch (Exception er)
            {
                Log("C:\\temp\\", "Error.log", er.ToString());
            }
        }
开发者ID:connecticutortho,项目名称:ct-ortho-repositories4,代码行数:32,代码来源:SendEmail.cs

示例8: Main

        static void Main(string[] args)
        {
            // Create attendees of the meeting
            MailAddressCollection attendees = new MailAddressCollection();
            attendees.Add("[email protected]");
            attendees.Add("[email protected]");

            // Set up appointment
            Appointment app = new Appointment(
                "Location", // location of meeting
                DateTime.Now, // start date
                DateTime.Now.AddHours(1), // end date
                new MailAddress("[email protected]"), // organizer
                attendees); // attendees

            // Set up message that needs to be sent
            MailMessage msg = new MailMessage();
            msg.From = "[email protected]";
            msg.To = "[email protected]";
            msg.Subject = "appointment request";
            msg.Body = "you are invited";

            // Add meeting request to the message
            msg.AddAlternateView(app.RequestApointment());

            // Set up the SMTP client to send email with meeting request
            SmtpClient client = new SmtpClient("host", 25, "user", "password");
            client.Send(msg);
        }
开发者ID:ruanzx,项目名称:Aspose_Email_NET,代码行数:29,代码来源:Program.cs

示例9: ParseAddressList

        internal override MailAddress[] ParseAddressList(string list)
        {
            List<MailAddress> mails = new List<MailAddress>();

            if (string.IsNullOrEmpty(list))
                return mails.ToArray();

            foreach (string part in SplitAddressList(list))
            {
                MailAddressCollection mcol = new MailAddressCollection();
                try
                {
                    // .NET won't accept address-lists ending with a ';' or a ',' character, see #68.
                    mcol.Add(part.TrimEnd(';', ','));
                    foreach (MailAddress m in mcol)
                    {
                        // We might still need to decode the display name if it is Q-encoded.
                        string displayName = Util.DecodeWords(m.DisplayName);
                        mails.Add(new MailAddress(m.Address, displayName));
                    }
                }
                catch
                {
                    // We don't want this to throw any exceptions even if the entry is malformed.
                }
            }
            return mails.ToArray();
        }
开发者ID:hmanjarawala,项目名称:GitRepo,代码行数:28,代码来源:ImapMessageBuilder.cs

示例10: Run

        public static void Run()
        {
            // ExStart:GetMailTips
            // Create instance of EWSClient class by giving credentials
            IEWSClient client = EWSClient.GetEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain");
            Console.WriteLine("Connected to Exchange server...");
            // Provide mail tips options
            MailAddressCollection addrColl = new MailAddressCollection();
            addrColl.Add(new MailAddress("[email protected]", true));
            addrColl.Add(new MailAddress("[email protected]", true));
            GetMailTipsOptions options = new GetMailTipsOptions("[email protected]", addrColl, MailTipsType.All);

            // Get Mail Tips
            MailTips[] tips = client.GetMailTips(options);

            // Display information about each Mail Tip
            foreach (MailTips tip in tips)
            {
                // Display Out of office message, if present
                if (tip.OutOfOffice != null)
                {
                    Console.WriteLine("Out of office: " + tip.OutOfOffice.ReplyBody.Message);
                }

                // Display the invalid email address in recipient, if present
                if (tip.InvalidRecipient == true)
                {
                    Console.WriteLine("The recipient address is invalid: " + tip.RecipientAddress);
                }
            }
            // ExEnd:GetMailTips
        }
开发者ID:aspose-email,项目名称:Aspose.Email-for-.NET,代码行数:32,代码来源:GetMailTips.cs

示例11: Populate

 private void Populate(MailAddressCollection dest, IEnumerable<string> source)
 {
     foreach (string mail in source)
     {
         dest.Add(FromString(mail));
     }
 }
开发者ID:Hylaean,项目名称:Hylaean.Mail,代码行数:7,代码来源:SmtpSender.cs

示例12: ApplyMailAddressOverride

        /// <summary>
        /// Applies the override to a MailAddressCollection
        /// </summary>
        /// <param name="addresses">The addresses.</param>
        /// <returns></returns>
        protected MailAddressCollection ApplyMailAddressOverride(MailAddressCollection addresses)
        {
            if (clear)
            {
                addresses.Clear();
            }
            else
            {
                if (!string.IsNullOrEmpty(overrideString))
                {
                    addresses.Clear();
                    addresses.Add(overrideString);
                }

                if (!string.IsNullOrEmpty(prependString))
                {
                    var old = addresses.ToString();
                    addresses.Clear();
                    addresses.Add(prependString);
                    if(!string.IsNullOrWhiteSpace(old)) addresses.Add(old);
                }

                if (!string.IsNullOrEmpty(appendString))
                {
                    addresses.Add(appendString);
                }
            }

            return addresses;
        }
开发者ID:kmc059000,项目名称:trout.messagequeue,代码行数:35,代码来源:MailMessageOverride.cs

示例13: SendEmail

		/// <summary>
		/// Send a plain text email with the specified properties. The email will appear to come from the name and email specified in the
		/// EmailFromName and EmailFromAddress configuration settings. If the emailRecipient parameter is not specified, the email
		/// is sent to the address configured in the emailToAddress setting in the configuration file. The e-mail is sent on a 
		/// background thread, so if an error occurs on that thread no exception bubbles to the caller (the error, however, is
		/// recorded in the error log). If it is important to know if the e-mail was successfully sent, use the overload of this
		/// method that specifies a sendOnBackgroundThread parameter.
		/// </summary>
		/// <param name="emailRecipient">The recipient of the email.</param>
		/// <param name="subject">The text to appear in the subject of the email.</param>
		/// <param name="body">The body of the email. If the body is HTML, specify true for the isBodyHtml parameter.</param>
		public static void SendEmail(MailAddress emailRecipient, string subject, string body)
		{
			MailAddressCollection mailAddresses = new MailAddressCollection();
			mailAddresses.Add(emailRecipient);

			SendEmail(mailAddresses, subject, body, false, true);
		}
开发者ID:haimon74,项目名称:KanNaim,代码行数:18,代码来源:EmailController.cs

示例14: CreateMailMessage

		private void CreateMailMessage(DeliveryInfo deliveryInfo, MailMessage message)
		{
			var recipients = deliveryInfo.To;
			if (string.IsNullOrEmpty(recipients)) throw new ArgumentNullException(recipients);

			var addressCollection = new MailAddressCollection();

			if (!MailSettings.UseEmailTestMode) addressCollection.Add(recipients);
			else addressCollection.Add(MailSettings.TestEmailAddress);

			foreach (var address in addressCollection)
			{
				message.To.Add(EmailHelper.FixMailAddressDisplayName(address, MailSettings.EmailHeaderEncoding));
			}

			message.From = EmailHelper.FixMailAddressDisplayName(new MailAddress(deliveryInfo.From), MailSettings.EmailHeaderEncoding);

			message.BodyEncoding = Encoding.GetEncoding(MailSettings.EmailBodyEncoding);
			message.SubjectEncoding = Encoding.GetEncoding(MailSettings.EmailSubjectEncoding);
			message.HeadersEncoding = Encoding.GetEncoding(MailSettings.EmailHeaderEncoding);

			message.Body = deliveryInfo.Body;
			message.IsBodyHtml = deliveryInfo.IsBodyHtml;
			message.Subject = deliveryInfo.Subject;

			if (!string.IsNullOrEmpty(deliveryInfo.ReplyTo))
			{
				var replyToCollection = new MailAddressCollection { deliveryInfo.ReplyTo };

				foreach (var address in replyToCollection)
				{
					message.ReplyToList.Add(EmailHelper.FixMailAddressDisplayName(address, MailSettings.EmailHeaderEncoding));
				}
			}
		}
开发者ID:mtolgobolsky,项目名称:Notifications,代码行数:35,代码来源:EmailDeliveryMethod.cs

示例15: CopyToMailAddressCollection

 public void CopyToMailAddressCollection(Rebex.Mime.Headers.MailAddressCollection rmac, MailAddressCollection mac)
 {
     foreach (Rebex.Mime.Headers.MailAddress rma in rmac)
     {
         mac.Add(ToMailAddress(rma));
     }
 }
开发者ID:greenwall,项目名称:QMail,代码行数:7,代码来源:MailMessageConverter.cs


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