次の方法で共有


Example of setting headers with System.Net.Mail

Here is a partial sample on setting header fields with System.Net.Mail: 

//============================ Instance Message ===========================
oMsg = new System.Net.Mail.MailMessage();

//============================ Optional Settings ===========================

if (this.Priority.Length != 0)
{
if (this.Priority == "Non Urgent") { oMsg.Priority = System.Net.Mail.MailPriority.Low; };
if (this.Priority == "Normal") { oMsg.Priority = System.Net.Mail.MailPriority.Normal; };
if (this.Priority == "Urgent") { oMsg.Priority = System.Net.Mail.MailPriority.High; };
}

if (this.RequestReadReceipt == true)
{
oMsg.Headers.Add("Disposition-Notification-To", this.From);
}

if (this.RequestDeliveryReceipt == true)
{
oMsg.Headers.Add("Return-Receipt-To", this.From);
}

if (this.ReplyTo.Length != 0)
{
oMsg.ReplyTo = new MailAddress(this.ReplyTo);
}
if (this.ReturnPath.Length != 0)
{
oMsg.Headers.Add("Return-Path", this.ReturnPath);
}

if (this.Sender.Length != 0)
{
oMsg.Sender = new MailAddress(this.Sender);
}

if (this.Sensitivity.Length != 0)
{
oMsg.Headers.Add("Sensitivity", this.Sensitivity);
}

// Other mail headers -------------------------------------

if (this.MailHeaderName1.Length != 0)
{
oMsg.Headers.Add(this.MailHeaderName1, this.MailHeaderVal1);
}
if (this.MailHeaderName2.Length != 0)
{
oMsg.Headers.Add(this.MailHeaderName2, this.MailHeaderVal2);
}
if (this.MailHeaderName3.Length != 0)
{
oMsg.Headers.Add(this.MailHeaderName3, this.MailHeaderVal3);
}

Comments