0

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.
   }
HappyLee
  • 435
  • 4
  • 11
  • 2
    Probably, this question contains your answer http://stackoverflow.com/questions/6216893/can-i-turn-off-the-email-address-validation-in-system-net-mail – Steve Feb 07 '14 at 23:11
  • I would assume that internally you have a special e-mail account that handles fax messages. My assumption is based on this [pdf-article explaining how to send a fax](http://itweb.lau.edu.lb/ITIS/Network-Tel/fax-procedure.pdf):`‘/name=Newyork/fax=0012128702762/ (right.fax@lau.edu.lb)` – surfmuggle Feb 07 '14 at 23:22
  • @Steve, i looked at the link previously, that didn't help me at all. ConstructorInfo object from that link returns null. Could you post me a sample code? – HappyLee Feb 08 '14 at 00:14
  • Sorry, but I have no code to show, mine was just a search that stumbled upon that question. – Steve Feb 08 '14 at 08:58

0 Answers0