I need to send an email for which the "to" address will be in the format ToAddress = "[fax:faxnumber]" I get an exception -"The specified string is not in the form required for an e-mail address." Is there a way that I can do this?
EDIT CODE:
MailMessage mail = new MailMessage();
mail.Subject = "Hi";
string ToAddress = "[fax:faxNumber]";
mail.To.Add(ToAddress); - //i get a FormatException here
USed the link from comments-
string[] ToAddress = new string[]{ "[fax:", "123456789]"};
var ctor = typeof(System.Net.Mail.MailAddress).GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance,null,new Type[] { typeof(string), typeof(string), typeof(string)}, null);
if (ctor != null)
{
object obj = ctor.Invoke(new object[] { null, ToAddress[0], ToAddress[1] });
System.Net.Mail.MailAddress toAddressObj = (System.Net.Mail.MailAddress)obj;
mail.To.Add(toAddressObj); ----obj is - [fax:@123456789]- '@' is inserted before the number which i don't need.
}