Example of setting headers with System.Web.Mail


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


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


}



if (this.RequestReadReceipt == true)
{
    oMsg.Fields[“urn:schemas:mailheader:disposition-notification-to”] =  this.From;
}


if (this.RequestDeliveryReceipt == true)
{
    oMsg.Fields[“urn:schemas:mailheader:return-receipt-to”] = this.From;
}


if (this.ReplyTo.Length != 0)
{
    //oMsg.ReplyTo = this.ReplyTo;
    //oMsg.Headers.Add(“Return-Path”,this.ReplyTo);
    oMsg.Fields[“http://schemas.microsoft.com/cdo/configuration/senduserreplyemailaddress“] = this.ReplyTo;
}


if (this.ReturnPath.Length != 0)
{
    oMsg.Fields[“urn:schemas:mailheader:return-path”] = this.ReturnPath;
}


if (this.Sensitivity.Length != 0)
{
    //TODO: This should be working, but does not… it works in all other api tests
    oMsg.Fields[“urn:schemas:mailheader:sensitivity”] = this.Sensitivity;
}


if (this.Sender.Length != 0)
{
    oMsg.Fields[“http://schemas.microsoft.com/cdo/configuration/sendemailaddress“] = this.Sender;
}



// Other mail headers ——————————–


if (this.MailHeaderName1.Length != 0)
{
    oMsg.Fields[“urn:schemas:mailheader:” + this.MailHeaderName1]  = this.MailHeaderVal1;
}
if (this.MailHeaderName2.Length != 0)
{
    oMsg.Fields[“urn:schemas:mailheader:” + this.MailHeaderName2]  = this.MailHeaderVal2;
}
if (this.MailHeaderName3.Length != 0)
{
    oMsg.Fields[“urn:schemas:mailheader:” + this.MailHeaderName3]  = this.MailHeaderVal3;
}

Comments (1)

  1. So many good articles and resources I have found over the last month or so. Here is a good sampling of

Skip to main content