本文整理汇总了C#中System.Net.Mail.MailAddress.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# MailAddress.ToString方法的具体用法?C# MailAddress.ToString怎么用?C# MailAddress.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.Mail.MailAddress
的用法示例。
在下文中一共展示了MailAddress.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Build_ReplyToSpecified_AddsReplyToPart
public void Build_ReplyToSpecified_AddsReplyToPart()
{
var replyTo = new MailAddress("[email protected]", "Test Passed");
var message = BuildMessage(x => { x.ReplyToList.Clear(); x.ReplyToList.Add(replyTo); });
var result = FormPartsBuilder.Build(message);
result.AssertContains("h:Reply-To", replyTo.ToString());
}
示例2: Build_FromSpecified_AddsFromPart
public void Build_FromSpecified_AddsFromPart()
{
var from = new MailAddress("[email protected]", "Test Passed");
var message = BuildMessage(x => x.From = from);
var result = FormPartsBuilder.Build(message);
result.AssertContains("from", from.ToString());
}
示例3: btnSendReminder_Click
private void btnSendReminder_Click(object sender, EventArgs e)
{
ContactDataSet.PersonDataTable addresses = personTableAdapter.GetEmailAddresses();
//String[] emails = new string[addresses.Rows.Count];
string addr = "[email protected]";
for (int i = 0; i < addresses.Rows.Count; i++)
{
//emails[i] = addresses[i].Email;
addr += ", " + addresses[i].Email;
}
try
{
string body = "You are being cordially invited to The Open Door Church " + lblServiceTitle.Text + " service which is on " + dtpServiceDate.Value.ToLongDateString() + " starting at 10:00 A.M.";
MailAddress fr = new MailAddress("[email protected]", "Romone Mcfarlane from Open Door Church");
SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
client.EnableSsl = true;
client.Timeout = 10000;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Credentials = new NetworkCredential("[email protected]", "mcfarlane1");
MailMessage msg = new MailMessage(fr.ToString(), addr, lblServiceTitle.Text, body);
client.Send(msg);
MessageBox.Show("Reminder Sent Successfully.");
}
catch (Exception)
{
throw;
}
}
示例4: Build_ToSpecified_AddsToPart
public void Build_ToSpecified_AddsToPart()
{
var to = new MailAddress("[email protected]", "Test Passed");
var message = BuildMessage(x => { x.To.Clear(); x.To.Add(to); });
var result = FormPartsBuilder.Build(message);
result.AssertContains("to", to.ToString());
}
示例5: Build_CCSpecified_AddsCCPart
public void Build_CCSpecified_AddsCCPart()
{
var cc = new MailAddress("[email protected]", "Test Passed");
var message = BuildMessage(x => { x.CC.Clear(); x.CC.Add(cc); });
var result = FormPartsBuilder.Build(message);
result.AssertContains("cc", cc.ToString());
}
示例6: User
public User(uint id, string name, MailAddress email, UserType userType)
{
ID = id;
Name = name;
Email = email;
StringMailAddress = email.ToString();
UserType = userType;
}
示例7: TestAddress1
public void TestAddress1()
{
const string addressString = "[email protected]";
var address = new MailAddress(addressString);
Assert.AreEqual("eric", address.User, "Username incorrect");
Assert.AreEqual("ericdomain.com", address.Host, "Domain incorrect");
Assert.AreEqual(addressString, address.Address, "Address incorrect");
Assert.AreEqual(addressString, address.ToString(), "ToString incorrect");
}
示例8: sendMail
public static void sendMail(string toAddress, string subject, string message)
{
MailAddress From = new MailAddress("Dungeon Teller <[email protected]>");
MailAddress To = new MailAddress(toAddress);
MailMessage msg = new MailMessage(From, To);
msg.Subject = subject;
msg.Body = message;
try
{
string address = To.ToString();
string domain = address.Substring(address.IndexOf('@') + 1);
string mxRecord = DnsLookUp.GetMXRecords(domain)[0];
SmtpClient client = new SmtpClient(mxRecord);
client.SendAsync(msg, "message1");
}
catch (Exception ex)
{
MessageBox.Show(String.Format("Failed to send email with the following error:\n'{0}'", ex.Message), "Mail-Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
示例9: sendEmailToFollowUser
public void sendEmailToFollowUser(string email,string hash)
{
var fromAddress = new MailAddress("[email protected]", "Smart Audio City Guide");
var toAddress = new MailAddress(email);
string fromPassword = "smartAudio!";
string subject = "Your friend want a help";
string body = "Please click on link to follow your friend: http://smartaudiocityguide.azurewebsites.net/HelpMode/follow?hash=" + hash;
var smtp = new SmtpClient
{
Host = "smtp.gmail.com",
Port = 587,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential(fromAddress.Address, fromPassword)
};
var message = new MailMessage(fromAddress.ToString(), toAddress.ToString(), subject, body);
smtp.Send(message);
}
示例10: SendEmail
public void SendEmail(string message, RegisterViewModel model, string callbackUrl)
{
var boddy = new StringBuilder();
var boddyConf = new StringBuilder();
boddy.Append(message);
string confirmMessage = "Hi! " + model.Email + "<br/>"
+ "Click the link to confirm your account " +
callbackUrl;
boddyConf.Append(confirmMessage);
string bodyForConf = boddyConf.ToString();
string bodyFor = boddy.ToString();
string subjectFor = "Registration";
string subjectForConf = "Confirm Email";
string toFor = model.Email;
var mail = new MailAddress("[email protected]", "EGO-Administrators");
WebMail.SmtpServer = "pod51014.outlook.com";
WebMail.SmtpPort = 587;
WebMail.UserName = "[email protected]";
WebMail.Password = "Dut921208";
WebMail.From = mail.ToString();
WebMail.EnableSsl = true;
try { WebMail.Send(toFor, subjectFor, bodyFor); }
catch
{
// ignored
}
try { WebMail.Send(toFor, subjectForConf, bodyForConf); }
catch
{
//null
}
}
示例11: SendMail
public int SendMail(string body,string subject)
{
int success = 0;
try
{
MailAddress toAddress = new MailAddress(email, this.email);
SmtpClient smtp = new SmtpClient();
MailAddress fromAddress = new MailAddress(((NetworkCredential)smtp.Credentials).UserName, "TFN");
using (MailMessage message = new MailMessage()
{
Subject = subject,
Body = body,
})
{
message.IsBodyHtml = true;
message.From = fromAddress;
message.To.Add(new MailAddress(toAddress.ToString()));
smtp.Send(message);
success = 1;
}
}
catch
{
Console.WriteLine("error in sending mail");
success = 0;
}
return success;
}
示例12: CreateNotificationFor
/// <summary>
/// Takes a message and constructs an MDN for it.
/// </summary>
/// <param name="message">The message to send notification about.</param>
/// <param name="from">MailAddress this notification is from</param>
/// <param name="notification">The notification to create.</param>
/// <returns>The MDN.</returns>
public static NotificationMessage CreateNotificationFor(Message message, MailAddress from, Notification notification)
{
if (message == null)
{
throw new ArgumentNullException("message");
}
if (from == null)
{
throw new ArgumentNullException("from");
}
if (notification == null)
{
throw new ArgumentNullException("notification");
}
//
// Verify that the message is not itself an MDN!
//
if (message.IsMDN())
{
throw new ArgumentException("Message is an MDN");
}
string notifyTo = message.GetNotificationDestination();
if (string.IsNullOrEmpty(notifyTo))
{
throw new ArgumentException("Invalid Disposition-Notification-To Header");
}
string originalMessageID = message.IDValue;
if (!string.IsNullOrEmpty(originalMessageID))
{
notification.OriginalMessageID = originalMessageID;
}
if (!notification.HasFinalRecipient)
{
notification.FinalRecipient = from;
}
NotificationMessage notificationMessage = new NotificationMessage(notifyTo, from.ToString(), notification);
notificationMessage.AssignMessageID();
string originalSubject = message.SubjectValue;
if (!string.IsNullOrEmpty(originalSubject))
{
notificationMessage.SubjectValue = string.Format("{0}:{1}", notification.Disposition.Notification.AsString(), originalSubject);
}
notificationMessage.Timestamp();
return notificationMessage;
}
示例13: sendPasswordToUser
public void sendPasswordToUser(string email, string password)
{
var fromAddress = new MailAddress("[email protected]", "Smart Audio City Guide");
var toAddress = new MailAddress(email);
string fromPassword = "3434g$br!el!";
string subject = "Password for Smart Audio City Guide site";
string body = "Your new password for Smart Audio City Guide is " + password ;
var smtp = new SmtpClient
{
Host = "smtp.gmail.com",
Port = 587,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential(fromAddress.Address, fromPassword)
};
var message = new MailMessage(fromAddress.ToString(), toAddress.ToString(), subject, body);
smtp.Send(message);
}
示例14: CreateNotificationFor
/// <summary>
/// Takes a message and constructs an DSN for it.
/// </summary>
/// <param name="message">The message to send notification about.</param>
/// <param name="from">MailAddress this notification is from</param>
/// <param name="dsn">The dsn to create.</param>
/// <returns>The DSN.</returns>
public static DSNMessage CreateNotificationFor(Message message, MailAddress from, DSN dsn)
{
if (message == null)
{
throw new ArgumentNullException("message");
}
if (from == null)
{
throw new ArgumentNullException("from");
}
if (dsn == null)
{
throw new ArgumentNullException("dsn");
}
//
// Verify that the message is not itself an MDN!
//
if (message.IsMDN())
{
throw new ArgumentException("Message is an MDN");
}
string notifyTo = message.From.Value;
DSNMessage statusMessage = new DSNMessage(notifyTo, from.ToString(), dsn);
statusMessage.AssignMessageID();
statusMessage.SubjectValue = string.Format("{0}:{1}", "Rejected", message.SubjectValue);
statusMessage.Timestamp();
return statusMessage;
}
示例15: DirectAddress
/// <summary>
/// Creates a Direct address without associated certificates. (The associated certificates
/// and trust anchors must be later set from, e.g., an external store or source).
/// </summary>
/// <param name="address">The <see cref="MailAddress"/> representation of the address.</param>
public DirectAddress(MailAddress address)
: this(address.ToString())
{
}