Adds a custom header to the email header.
Fully test the header before you call this method in a production scenario. Not all mail readers support custom headers, and may munge the email to be unreadable. If you aren't sure about the custom header you want to add, use the AddXHeader() method.
[C#]
EmailMessage msg = new EmailMessage();
msg.Server = "Mail1.MyCompany.com";
msg.FromAddress = "me@MyCompany.com";
msg.AddTo( "you@YourCompany.com", "Billy Bob" );
msg.AddHeader( "Company Branch", "Midwestern Division");
msg.Subject = "Daily Newsletter";
msg.Body = "Here is our daily newsletter.....";
if ( msg.Send() )
{
Console.WriteLine( "Message Sent!");
}
else
{
Console.WriteLine( msg.LastException().Message );
}
[Visual Basic]
Dim msg As New EmailMessage()
msg.Server = "Mail1.MyCompany.com"
msg.FromAddress = "me@MyCompany.com"
msg.AddTo("you@YourCompany.com", "Billy Bob")
msg.AddCc("myBoss@MyCompany.com", "John Smith")
msg.AddHeader("Company Branch", "Midwestern Division")
msg.Subject = "Daily Newsletter"
msg.Body = "Here is our daily newsletter....."
If (msg.Send()) Then
Console.WriteLine("Message Sent!")
Else
Console.WriteLine(msg.LastException().Message)
End If