本文整理汇总了C#中MailAddressCollection.Add方法的典型用法代码示例。如果您正苦于以下问题:C# MailAddressCollection.Add方法的具体用法?C# MailAddressCollection.Add怎么用?C# MailAddressCollection.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MailAddressCollection
的用法示例。
在下文中一共展示了MailAddressCollection.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: 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
}
示例3: 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));
}
}
}
示例4: Run
public static void Run()
{
// ExStart:AddMembersToPrivateDistributionList
IEWSClient client = EWSClient.GetEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain");
ExchangeDistributionList[] distributionLists = client.ListDistributionLists();
MailAddressCollection newMembers = new MailAddressCollection();
newMembers.Add("[email protected]");
newMembers.Add("[email protected]");
client.AddToDistributionList(distributionLists[0], newMembers);
// ExEnd:AddMembersToPrivateDistributionList
}
示例5: Run
public static void Run()
{
// ExStart:DeleteMembersFromPrivateDistributionList
IEWSClient client = EWSClient.GetEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain");
ExchangeDistributionList[] distributionLists = client.ListDistributionLists();
MailAddressCollection members = client.FetchDistributionList(distributionLists[0]);
MailAddressCollection membersToDelete = new MailAddressCollection();
membersToDelete.Add(members[0]);
membersToDelete.Add(members[1]);
client.DeleteFromDistributionList(distributionLists[0], membersToDelete);
// ExEnd:DeleteMembersFromPrivateDistributionList
}
开发者ID:aspose-email,项目名称:Aspose.Email-for-.NET,代码行数:12,代码来源:DeleteMembersFromPrivateDistributionList.cs
示例6: Run
public static void Run()
{
// ExStart:CreatePrivateDistributionList
IEWSClient client = EWSClient.GetEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain");
ExchangeDistributionList distributionList = new ExchangeDistributionList();
distributionList.DisplayName = "test private list";
MailAddressCollection members = new MailAddressCollection();
members.Add("[email protected]");
members.Add("[email protected]");
members.Add("[email protected]");
client.CreateDistributionList(distributionList, members);
// ExEnd:CreatePrivateDistributionList
}
示例7: 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));
}
}
示例8: 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);
}
示例9: AddMailAddress
static void AddMailAddress(MailAddressCollection collection, String address)
{
if (String.IsNullOrEmpty(address))
return;
if (address.Contains(";"))
{
String[] recipients = address.Split(';');
foreach (String recipient in recipients)
collection.Add(recipient);
}
else
{
collection.Add(address);
}
}
示例10: 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());
}
}
示例11: 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;
}
}
示例12: 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);
}
示例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);
}
示例14: Populate
private void Populate(MailAddressCollection dest, IEnumerable<string> source)
{
foreach (string mail in source)
{
dest.Add(FromString(mail));
}
}
示例15: CopyToMailAddressCollection
public void CopyToMailAddressCollection(Rebex.Mime.Headers.MailAddressCollection rmac, MailAddressCollection mac)
{
foreach (Rebex.Mime.Headers.MailAddress rma in rmac)
{
mac.Add(ToMailAddress(rma));
}
}